#include <iostream>
#include <string>
using namespace std;
int n;
string fisiere[100];
int main() {
cin >> n;
getline(cin, fisiere[0]);
for (int i = 1; i <= n; ++i) {
getline(cin, fisiere[i]);
}
char litera;
cin >> litera;
string rez;
for (int i = 0; i < n; ++i) {
if (fisiere[i][0] == litera && (rez == "" || rez > fisiere[i])) {
rez = fisiere[i];
}
}
cout << rez;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG47CnN0cmluZyBmaXNpZXJlWzEwMF07CgppbnQgbWFpbigpIHsKCWNpbiA+PiBuOwoJZ2V0bGluZShjaW4sIGZpc2llcmVbMF0pOwoJZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CgkgIGdldGxpbmUoY2luLCBmaXNpZXJlW2ldKTsKCX0KCWNoYXIgbGl0ZXJhOwoJY2luID4+IGxpdGVyYTsKCXN0cmluZyByZXo7Cglmb3IgKGludCBpID0gMDsgaSA8IG47ICsraSkgewoJICBpZiAoZmlzaWVyZVtpXVswXSA9PSBsaXRlcmEgJiYgKHJleiA9PSAiIiB8fCByZXogPiBmaXNpZXJlW2ldKSkgewoJICAgIHJleiA9IGZpc2llcmVbaV07CgkgIH0KCX0KCWNvdXQgPDwgcmV6OwoJcmV0dXJuIDA7Cn0=