1 | #include <bits/stdc++.h> |
2 | |
3 | using namespace std; |
4 | |
5 | int main() { |
6 | int n; |
7 | cin >> n; |
8 | |
9 | map<multiset<int>, int> mp; |
10 | |
11 | for (int i = 0; i < n; ++i) { |
12 | int m; |
13 | cin >> m; |
14 | multiset<int> b; |
15 | for (int j = 0; j < m; ++j) { |
16 | int x; |
17 | cin >> x; |
18 | b.insert(x); |
19 | } |
20 | |
21 | mp[b]++; |
22 | } |
23 | |
24 | int q; |
25 | cin >> q; |
26 | for (int i = 0; i < q; ++i) { |
27 | int m; |
28 | cin >> m; |
29 | multiset<int> b; |
30 | for (int j = 0; j < m; ++j) { |
31 | int x; |
32 | cin >> x; |
33 | b.insert(x); |
34 | } |
35 | |
36 | if (mp.find(b) != mp.end()) { |
37 | cout << mp[b] << endl; |
38 | } else { |
39 | cout << 0 << endl; |
40 | } |
41 | } |
42 | |
43 | |
44 | return 0; |
45 | } |
46 | |