Problem H
Boxes
There are
You have to answer a series of queries of the following form: given a list of indices of the boxes, find the total number of boxes that the list of boxes actually contain.
Consider, for example, the following five boxes.
![\includegraphics[width=0.5\textwidth ]{Boxes}](/problems/boxes/file/statement/en/img-0001.png)
-
If the query is the list “1”, then the correct answer is “5”, because box 1 contains all boxes.
-
If the query is the list “4 5”, then the correct answer is “2”, for boxes 4 and 5 contain themselves and nothing else.
-
If the query is the list “3 4”, then the correct answer is “2”.
-
If the query is the list “2 3 4”, then the correct answer is “4”, since box 2 also contains box 5.
-
If the query is the list “2”, then the correct answer is “3”, because box 2 contains itself and two other boxes.
Input
The first line contains the integer
The second line contains
The third line contains an integer
Output
For each query, output a line which contains an integer representing the total number of boxes.
Sample Input 1 | Sample Output 1 |
---|---|
5 0 1 1 2 2 5 1 1 2 4 5 2 3 4 3 2 3 4 1 2 |
5 2 2 4 3 |