403068: GYM100989 F Mission in Amman (A)
Description
You must have heard about Agent Mahone! Dr. Ibrahim hired him to catch the cheaters in the Algorithms course. N students cheated and failed this semester and they all want to know who Mahone is in order to take revenge!
Agent Mahone is planning to visit Amman this weekend. During his visit, there are M places where he might appear. The N students are trying to cover these places with their leader Hammouri, who has been looking for Mahone since two semesters already!
Hammouri will be commanding students to change their places according to the intel he receives. Each time he commands a student to change his position, he wants to know the number of places that are not covered by anyone.
Can you help these desperate students and their leader Hammouri by writing an efficient program that does the job?
InputThe first line of input contains three integers N, M and Q (2 ≤ N, M, Q ≤ 105), the number of students, the number of places, and the number of commands by Hammouri, respectively.
Students are numbered from 1 to N. Places are numbered from 1 to M.
The second line contains N integers, where the ith integer represents the location covered by the ith student initially.
Each of the following Q lines represents a command and contains two integers, A and B, where A (1 ≤ A ≤ N) is the number of a student and B (1 ≤ B ≤ M) is the number of a place. The command means student number A should go and cover place number B. It is guaranteed that B is different from the place currently covered by student A.
Changes are given in chronological order.
OutputAfter each command, print the number of uncovered places.
ExampleInput4 5 4Output
1 2 1 2
1 3
2 4
4 5
3 5
2
1
1
2