
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char q[1010];
char w[1010];
int main()
{
scanf("%s",q);
getchar();
string s=q;
int len=s.size();
for(int i=0; i<len; i++)
{
s[i]=tolower(s[i]);
}
while(gets(w))
{
string in=w;
string out=w;
int lenw=in.size();
for(int i=0; i<lenw; i++)
{
in[i]=tolower(in[i]);
}
int pos=in.find(s,0);
while(pos!=string::npos)
{
out.erase(pos,len);
in.erase(pos,len);
pos=in.find(s,pos);
}
pos=out.find(' ',0);
while(pos!=string::npos)
{
out.erase(pos,1);
pos=out.find(' ',pos);
}
cout<<out<<endl;
}
return 0;
}