시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
3 초 128 MB 11 3 3 27.273%

문제

In any society there are social influence relations between individuals, where a person x can influence another person y. The same is true for Softopia, a special society where social influence relations are also transitive, meaning that if x can influence y and y can influence z, then x also influences z. Moreover, the rules of social influence guarantee that if x influences any other person y, then x cannot be influenced by y as well. Using these simple rules, if a person x from Softopia wants something, then all the nodes influenced by x also want the same thing.

Although, Softopia is almost a perfect society, there is a set of certain individuals, X, that would spread false demands through the social influence mechanism used by the society. And there is also an evil entity that would want to find out which of these people should be selected to spread a demand of their own. Because the society can only select one person from X, it would like to select one that is able to influence as many people as possible from Softopia. If there is more than a person that satisfies this request, you should pick the one with the lowest identifier.

입력

The input file starts with a line containing two integers separated by one space: n (n ≤ 5000) the number of individuals in the society, and k, the number of elements in set X. The next line contains the elements from X, thus k different integers from 1..n separated by one space. Then follow n lines and each line i, 1≤i≤n, contains first the identifier of the current person followed by the identifiers of the persons that can be directly influenced by person i, all of them separated by a space. The persons are labeled from 1 to n. The total number of influences in a society is less than 250000. Additional whitespaces in the input file should be skipped.

출력

The result, representing the identifier of the person that satisfies the conditions mentioned above, will be written on a single line.

예제 입력

5 2
1 2
1 3 4
2 3 4
3 5
4 5
5

예제 출력

1

예제 입력 2

6 3
1 2 3
1 2
2 5
3 4 2
4 6
5
6

예제 출력 2

3

힌트