#include #include #include #include using namespace std; int main() { string s, word, word2; istringstream ss; int n; getline(cin, s); ss = istringstream(s); ss >> n; unordered_map M; while (n--) { getline(cin, s); for (auto &ch : s) if ('A' <= ch && ch <= 'Z') ch = ch - 'A' + 'a'; //cout << "*** " << s << endl; ss = istringstream(s); string name, word; ss >> name; while (ss >> word) M[word] = name; } while (getline(cin, s)) { for (auto &ch : s) if (ch == ',' || ch == '.' || ch == '(' || ch == ')' || ch == '[' || ch == ']' || ch == '{' || ch == '}' || ch == '<' || ch == '>' || ch == ';' || ch == '!' || ch == '?') ch = ' '; else if ('A' <= ch && ch <= 'Z') ch = ch - 'A' + 'a'; ss = istringstream(s); while (ss >> word) { auto ite = M.find(word); if (ite != M.end()) { cout << ite->second << endl; goto outer; } } outer:; } return 0; }