After the events that took place in New York, the worlds from the Marvel Universe are at war. The world is represented, in this final war, by an army consisting of soldiers (possibly zero). Each soldier has a single super power represented by a positive integer (between and ). The powers of all the soldiers in an army are different.
It has been observed that, in direct battle, two soldiers annihilate each other if and only if they have the same power. For example, if an army consisting of soldiers with powers battles an army , the following soldiers remain alive at the end of the battle: .
The worlds are arranged sequentially. The first world has index and the last world has index .
Task
Thanos is pretty sure that he can win the war and destroy the universe, but he also wants to have fun while doing it. He has prepared questions for you. For each question you are given two indexes and and you have to find the number of soldiers that would survive a battle between the armies with indexes .
Input
The first line of the input file infinitywar.in
contains two numbers and .
The next lines contain the descriptions of the armies. Line (where ) contains a number (number of soldiers) followed by numbers (power number of each soldier).
The next lines each contain two numbers and separated by a space.
Output
The output file infinitywar.out
must contain lines. Each line must contain a single number, the answer to the corresponding question.
Constraints and notes
- for every question.
- For of tests: şi
- For another of tests: şi
Example
infinitywar.in
4 3
2 1 2
3 1 3 97
2 1 341
5 4 2 981 341 97
1 3
2 4
1 4
infinitywar.out
5
4
4