[ABC329F] 彩球盒子合并 (Colored Ball)
Score : points
Problem Statement
There are boxes numbered . Initially, box contains one ball of color .
You are given queries, which you should process in order.
Each query is given by a pair of integers and asks you to do the following:
- Move all the balls from box to box , and then print the number of different colors of balls in box .
Here, the boxes and may be empty.
Constraints
-
-
-
-
-
All input values are integers.
Input
The input is given from Standard Input in the following format, where represents the -th query:
$N$ $Q$
$C_1$ $C_2$ $\ldots$ $C_N$
$\text{query}_1$
$\text{query}_2$
$\vdots$
$\text{query}_Q$
Each query is given in the following format:
$a$ $b$
Output
Print lines. The -th line should contain the response to the -th query.
Sample Input 1
6 5
1 1 1 2 2 3
1 2
6 4
5 1
3 6
4 6
Sample Output 1
1
2
1
1
3
-
For the first query, move all the balls from box to box . Box now contains two balls of color , so print .
-
For the second query, move all the balls from box to box . Box now contains one ball of color and one ball of color , so print .
-
For the third query, move all the balls from box to box . Box now contains one ball of color , so print .
-
For the fourth query, move all the balls from box to box . Box now contains one ball of color , so print .
-
For the fifth query, move all the balls from box to box . Box now contains one ball of color , one ball of color , and one ball of color , so print .
Sample Input 2
5 3
2 4 2 4 2
3 1
2 5
3 2
Sample Output 2
1
2
0