#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;
vector<map<string,int>> v_m(N);
int n,m;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;
int li;
for(int i=1;i<=n;i++){
cin>>li;
string str;
for(int j=1;j<=li;j++){
cin>>str;
v_m[i][str]++;
}
}
cin>>m;
string str;
for(int i=1;i<=m;i++){
cin>>str;
for(int j=1;j<=n;j++){
if(v_m[j].count(str)!=0){
cout<<j<<" ";
}else{
continue;
}
}
cout<<endl;
}
return 0;
}

京公网安备 11010502036488号