#include using namespace std; #define ll long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) int main() { vector> ss(21); int N; cin>>N; rep(_i, N) { int p; cin>>p; if(p==0) { int n,m; cin>>n>>m; rep(i,m) { string s; cin>>s; ss[n].insert(s); } } else if(p==1) { string b; cin>>b; bool f=true; rep(i,21) { if(ss[i].find(b)!=ss[i].end()) { auto itr = ss[i].find(b); ss[i].erase(itr); cout<>c; ss[c].clear(); } } return 0; }