// 好气人,你也没说要去重啊,
// 卡了半天
#include <bits/stdc++.h>
using namespace std;
//
void solve() {
int n;
cin >> n;
// 不是哥们,你也没说要去重啊?????
unordered_map<string,set<int>>mp;
for (int i = 1;i <= n;i++)
{
int l;cin>>l;
while (l--)
{
string s;cin>>s;
mp[s].insert(i);
}
}
int m;cin>>m;
for (int i = 0;i < m;i++)
{
string s;cin>>s;
for (int j:mp[s])
{
cout<<j<<' ';
}
cout<<'\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}

京公网安备 11010502036488号