#include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF 1 << 29 #define LL long long int LL const MOD = 1000000007; int main(){ cin.tie(0); ios::sync_with_stdio(false); vector onkyaku(21,false); vector> eatlist(21); LL n; cin >> n; for(int i = 0; i < n; i++){ LL d; cin >> d; if(d == 0){ LL ind; cin >> ind; LL listnum; cin >> listnum; for(int j = 0; j < listnum; j++){ string inp; cin >> inp; eatlist[ind].push_back(inp); onkyaku[ind] = true; } }else if(d == 1){ string str; cin >> str; bool frag = true; LL out = -1; for(int j = 1; frag && j < 21; j++){ if(onkyaku[j]){ for(int k = 0;frag && k < eatlist[j].size(); k++){ if(str == eatlist[j][k]){ out = j; frag = false; eatlist[j].erase(eatlist[j].begin() + k); } } } } cout << out << endl; }else{ LL c; cin >> c; while(eatlist[c].size() > 0){ eatlist[c].erase(eatlist[c].begin()); } } } return 0; }