#include #include #include #include #include #include #include #include using namespace std; int main() { //int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0; long long a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0; //cout << LONG_MAX << endl; //string s[1001]; //long long n, A[1000000000]; long long n, m; string s[21][11]; cin >> n; int ni, mi; string bi; for (a = 0; a < n; a++) { cin >> m; if (m == 0) { cin >> ni; cin >> mi; for (b = 0; b < mi; b++) { cin >> s[ni][b]; } } if (m == 1) { cin >> bi; d = 0; for (b = 0; b < 20; b++) { for (c = 0; c < 10; c++) { if (bi == s[b][c]) { cout << b << endl; s[b][c] = ""; b = 20; d = 1; break; } } } if (d==0) { cout << -1 << endl; } } if (m == 2) { cin >> mi; for ( b = 0; b < 10; b++) { s[mi][b] = " "; } } } //std::cout << std::fixed; //cout << std::setprecision(20) << << endl; //cout << d << endl; return 0; }