#include using namespace std; using ll = long long; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N; map mp[25]; while(N--){ ll id; cin >> id; if(id==0){ ll seat; cin >> seat; ll m; cin >> m; FOR(i, 0, m){ string neta; cin >> neta; mp[seat][neta]++; } } else if(id==1){ string neta; cin >> neta; bool sushi_taken = false; FOR(i, 1, 21){ if(mp[i][neta]>0){ mp[i][neta]--; p(i); sushi_taken = true; break; } } if(!sushi_taken) p(-1); } else{ ll C; cin >> C; mp[C].clear(); } } return 0; }