#include using namespace std; int n, m, cnt; int flag[500000]; unordered_map match; vector G[100010]; int main() { cin >> n; for (int i = 1; i <= n; i++) { int opt; cin >> opt; for (int j = 1; j <= opt; j++) { string op; cin >> op; if (!match[op]) { cnt++; match[op] = cnt;//映射成数字 G[cnt].push_back(i); } else { G[match[op]].push_back(i); } } } cin >> m; for (int i = 1; i <= m; i++) { string opt; cin >> opt; memset(flag, 0, sizeof(flag)); for (int j = 0; j < G[match[opt]].size(); j++) { if (flag[G[match[opt]][j]])continue;//判重 flag[G[match[opt]][j]] = 1; cout << G[match[opt]][j] << ' '; } cout << '\n'; } return 0; }