You are given an array of integers and then queries. Each query consists of
two indices . If the -th
value in the list is
and the -th value in
the list is , then all
instances of in the
list should be replaced by a . Then the number of -es that were in the list before
the change should be printed, followed by a single space, and
then the number of -s
in the list after the change should be printed.
Input
The input starts with a single integer . Then the
integers in the array
are written on a single line, separated by spaces, in order.
The integers in the array are in the interval . Then there is a
single line with . Finally there are lines, each with two indices
separated by a
space, as described above.
Output
Two integers separated by a space on their own line for each
query, as described above.
Sample Input 1 |
Sample Output 1 |
6
1 2 3 4 5 6
4
2 4
3 4
6 5
4 5
|
1 2
1 3
1 2
3 5
|