#include<stdio.h>
#include<string.h>
void getNext(char s[],int len,int next[])
{
next[0]=-1;
int j=next[0];
for(int i=1; i<len; i++)
{
while(j!=-1&&s[i]!=s[j+1])
j=next[j];
if(s[i]==s[j+1])
{
next[i]=j+1;
j++;
}
else
{
next[i]=j;
}
}
}
bool KMP(char text[],char pattern[],int next[])
{
int n=strlen(text),m=strlen(pattern);
getNext(pattern,m,next);
int j=-1;
for(int i=0; i<n; i++)
{
while(j!=-1&&text[i]!=pattern[j+1])
j=next[j];
if(text[i]==pattern[j+1])
{
j++;
}
if(j==m-1)
return true;
}
return false;
}
int main()
{
char text[100],pattern[100];
int next[100]= {0};
gets(text);
gets(pattern);
char s[2][10]={"is not","is"};
printf("%s %s a substring of %s",pattern,s[KMP(text,pattern,next)],text);
return 0;
}