#include <iostream>
#include <cstring>
using namespace std;
int n;
char s[256],cuv[256],c;
int main()
{
cin >> n;
for(;n;n--)
{
cin >> cuv;
strcat(s,cuv);
if(n!=1)
strcat(s," ");
}
cin >> c;
char *p=strtok(s," ");
while(p!=NULL)
{
if(strchr(p,c))
cout << p << " ";
p=strtok(NULL," ");
}
return 0;
}