Big P has become a Physical Education teacher at Hack International School.
Today, the students of class XII have been very undisciplined and he decides to punish them all.
He makes all of the N student (numbered 1 to N ) to stand in a line and asks them to sit down on their knees.
Students know that Big P is a very cruel and sadistic person and students start to sit down themselves when they see a friend sit down.
However, there are always some students who do not follow the trend. Now when Big P sees that happen , he slaps that student and makes him sit down. The same process as above is followed and is stopped when any - one student in the line refuses to sit down by himself.
Given the students that Big P slaps to make them sit down , you need to tell the total no. of students who sat down in that line.
Note: It is not necessary that if A is friend of B then B is also friend of A.
Input Format :
First Line Contains an integer T denoting no of test cases.
Each test case begins with a line containing three integers \(N, F, S\) where N is the number of students in the line. Next F lines have two integers A and B denoting the friendship between the students A and B. Next S lines have one integer X denoting the student that was slapped by Big P .
Output Format:
For each test case, output a line containing one integer, the total number of students that sit down in that line.
\( T \le 10 , N ,F , S \le 10000 \)
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial