#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int n,m,cnt;
string s[100006];
char k;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>s[i];
}
cin>>k;
sort(s+1,s+n+1);
for(int i=1;i<=n;i++){
if(s[i].find(k)==0) cout<<s[i]<<"\n";
}
return 0;
}
P1628
WA40