#include #include using namespace std; map> p; void process(int data) { switch (data) { case 0: { int n, m; cin >> n >> m; p[n].resize(m); for (int i = 0; i < m; i++) { string a; cin >> a; p[n].push_back(a); } return; } case 1: { string b; cin >> b; for (int i = 1; i < 20; i++) for (int j = 0; j < p[i].size(); j++) if (b == p[i][j]) { cout << i << endl; p[i].erase(p[i].begin() + j); return; } cout << -1 << endl; return; } case 2: { int c; cin >> c; p[c].resize(0); return; } } } int main() { int n; cin >> n; for (int i = 0; i < n; i++) { int d; cin >> d; process(d); } return 0; }