/*
TASK: CONTEXT
LANG: C++
*/
#include<iostream>
#include<string>
using namespace std;
int main()
{
    char p;
    int i,j,n,m,k;
    string a="",b="",r="",r2="";
    cin>>n;
    getline(cin,r2);
    getline(cin,a);
    getline(cin,b);
    m=a.size();
    k=b.size();
    int s=0,e=m-2;
    r="";
    while(a[s]==' ') s++;
    while(a[e]==' ') e--;
    for(i=s;i<=e+1;i++) r+=a[i];
    a=r;
    r=""; s=0; e=k-1;
    while(b[s]==' ') s++;
    while(b[e]==' ') e--;
    for(i=s;i<=e+1;i++) r+=b[i];
    b=r;
    m=a.size();
    k=b.size();
    for(i=0;i<=k-m+1;i++)
    {
        char t;
        if((int)b[i]>64&&(int)b[i]<91) t=(char)((int)b[i]+32);
        if((int)b[i]>96&&(int)b[i]<123) t=(char)((int)b[i]-32);
        if(b[i]==a[0]||a[0]==t)
        {
            int check=1,pos=0;
            for(j=i;j<m+i;j++)
            {
                if((int)b[j]>64&&(int)b[j]<91) t=(char)((int)b[j]+32);
                if((int)b[j]>96&&(int)b[j]<123) t=(char)((int)b[j]-32);
                if(a[pos]!=b[j]&&a[pos]!=t) check=0;
                pos++;
            }
            if(check)
            {
                if(i-n<1)
                {
                    if(i+m+n+n-i<k)
                    cout<<b.substr(0,2*n+m)<<'\n';
                    else cout<<b<<'\n';
                }
                else
                if(i+m+n>=k)
                {
                    if(i-n-n+k-i-m>=1)
                    cout<<b.substr(i-2*n+k-i-m-1,2*n+m)<<'\n';
                    else cout<<b<<'\n';
                }
                else cout<<b.substr(i-n,2*n+m)<<'\n';
           }
        }
    }
    return 0;
}
