#include<iostream>
using namespace std;
#include <queue>
priority_queue<string,vector<string>,greater<string> >s;
int main()
{
int m,length,i;
string ps[100000];
char k;
cin>>m;
cin.get(k);
for(i=1;i<=m;i++)
{
getline(cin,ps[i]);
}
getline(cin,ps[m+1]);
for(i=1;i<=m;i++)
{
if(ps[i].find(ps[m+1])==0)
{
string e;
e=ps[i];
s.push(e);
}
}
while(!s.empty())
{
cout<<s.top();
s.pop();
if(!s.empty())
cout<<endl;
}
}