#include #include using namespace std; struct seat { bool tmp; int m; string A[20]; }; int main() { int N, data, nC, j, k; string B; seat list[20] = {}; cin >> N; for (int i = 0; i < N; ++i) { cin >> data; if (data == 0) { cin >> nC >> list[nC - 1].m; list[nC - 1].tmp = true; for (j = 0; j < list[nC - 1].m; ++j) cin >> list[nC - 1].A[j]; } else if (data == 1) { cin >> B; for (j = 0; j < 20; ++j) { if (list[j].tmp == false) continue; for (k = 0; k < list[j].m; ++k) { if (list[j].A[k] == B) { list[j].A[k] = ""; break; } } if (k != list[j].m) break; } if (j == 20) cout << -1; else cout << j + 1; cout << endl; } else { cin >> nC; list[nC - 1].tmp = false; } } }