#include "map"
#include "iostream"
#include "cstring"
#include <algorithm>
#include <cstdio>
#include <string>
using namespace std;
const int N = 100010;
map<string, string > cidian ;
int n;
int main() {
    string plus;
    while (getline(cin, plus)) {
        string mozhou, func;
        if (plus == "@END@") break;;
        int p2 = plus.find(']');
        mozhou = plus.substr(0,p2+1);
        func = plus.substr(p2 + 2);
        cidian[mozhou] = func;
        cidian[func] = mozhou;
    }
    scanf("%d", &n);
    getchar();
    while (n--) {
        string test;
        getline(cin, test);
        string ans=cidian[test];
        if (ans=="") {
            ans="what?";
        } else if(ans[0]=='['){
            ans= ans.substr(1,ans.size()-2);
        }
        cout << ans <<endl;
    }

    return 0;
}

哈希表