Problem E
Panda Chess

In the city of Pandaville, the predominant black and white
colours of the inhabitants have somehow made chess a very
popular game in the area. There are a total of
Each chess player is identified by his/her unique IC number
which is a number containing at most
The ranking list published is typed by a panda writer using
a typewriter. Due to his fat paws, the panda writer makes a lot
of mistakes. You are asked to amend the ranking list.
Input
The input consists of:
-
One line with three integers
( ), ( ) and ( ), where is the number of chess players, is the number of matches played, and is the maximum number of digits for each IC number; -
lines each with two IC numbers and , indicating that panda A wins over panda B; -
lines each with one IC number , representing the ranking list typed by the panda writer;
It is guaranteed that the
Output
Output one line with a single integer: the minimum number of edits required to obtain the actual ranking list from the original ranking list typed by the panda writer.
Sample Input 1 | Sample Output 1 |
---|---|
4 4 3 345 678 12 345 345 678 678 999 999 12 824 999 |
4 |