#include <stdio.h>;
#include <iostream>
#include <math.h>
#include<cstdio>
#include<algorithm>
using namespace ::std;
int n;
string s[1000010],m;
bool fun(string t) {
string x;
for (int i = 0; i < m.length(); i++) {
x += t[i];
}
if (x == m)return true;
else return false;
}
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf(" %s", &s[i]);
}
scanf(" %s", &m);
sort(s + 1, s + 1 + n);
for (int i = 1; i <= n; i++) {
if (fun(s[i])) {
cout << s[i] << endl;
}
}
return 0;
}