#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" using namespace std; #define rep(i, n) for(int i=0; i<(n); ++i) #define FOR(i, m, n) for(int i=(m); i<(n); ++i) #define sz(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() #define mp make_pair #define pb push_back #define Cout(x) cout << (x) << endl #define dump(x) cerr << #x << " = " << (x) << endl; typedef long long LL; typedef vector VI; typedef vector VL; typedef vector VS; typedef vector> VVI; typedef pair PII; const int inf = (int)1e9; const long long mod = (long long)1e9 + 7; const double pi = acos(-1.0); int main() { vector>> t(20); rep(i, 20)t[i].first = false; int n; cin >> n; rep(i, n) { int q; cin >> q; if (q == 0) {//set int n, m; cin >> n >> m; n--; t[n].first = true; rep(i, m) { string name; cin >> name; t[n].second.pb(name); } } else if (q == 1) {//susi string s; cin >> s; int ans = -1; rep(i, 20) { if (t[i].first) { rep(j, sz(t[i].second))if (ans == -1 && t[i].second[j] == s) { ans = i + 1; t[i].second.erase(t[i].second.begin() + j); } } } Cout(ans); } else if (q == 2) {//delete int c; cin >> c; c--; t[c].second.clear(); t[c].first = false; } } }