AT_past202303_f 集合の問題

Description

Given a set of $ N $ integers, $ S=\{S_1,S_2,\dots,S_N\} $ , answer $ Q $ queries in the following format: - given a set of $ M $ integers, $ T=\{T_1,T_2,\dots,T_M\} $ , find how many integers the union of $ S $ and $ T $ contains.

Input Format

The input is given from Standard Input in the following format: > $ N $ $ S_1 $ $ S_2 $ $ \dots $ $ S_N $ $ Q $ $ \rm{Query}_{1} $ $ \rm{Query}_{2} $ $ \vdots $ $ \rm{Query}_{Q} $ Here, $ \rm{Query}_{i} $ denotes the $ i $ -th query. Each query is given in the following format: > $ M $ $ T_1 $ $ T_2 $ $ \dots $ $ T_M $

Output Format

Print $ Q $ lines. The $ i $ -th line should contain the answer to the $ i $ -th query as an integer.

Explanation/Hint

### Sample Explanation 1 In this input, $ S=\{2,3,5,7,11\} $ , and five queries are given. - In the first query, $ T=\{1,3,5,7,9,11\} $ . The union of $ S $ and $ T $ is $ \{1,2,3,5,7,9,11\} $ , which contains seven integers. - In the second query, $ T=\{12,10,8,6,4,2\} $ . The union of $ S $ and $ T $ is $ \{2,3,4,5,6,7,8,10,11,12\} $ , which contains ten integers. ### Constraints - All values in the input are integers. - $ 1 \le N \le 2 \times 10^5 $ - $ 1 \le S_i \le 10^9 $ - If $ i \neq j $ , then $ S_i \neq S_j $ . - All queries satisfy the following conditions: - $ 1 \le M $ - If $ i \neq j $ , then $ T_i \neq T_j $ . - The sum of $ M $ in an input does not exceed $ 2 \times 10^5 $ .