시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 0 0 0 0.000%

문제

In the Mysterious Land of Worms there are many worm-houses. Not all of them are inhabited. It is known however, that at most one worm lives in each house. Some pairs of houses are connected with a path. For any pair of two different houses there exists exactly one route consisting of paths, so that none of the paths repeats on the route.

One day, all of the worms decided to meet in one of the houses. They agreed that every hour each of them will move along a path leaving the house it is presently in and will go to the other house at the opposite end of that path (walking along any path in the Mysterious Land of Worms takes exactly one hour). Worms intend to continue their travel untill the moment, when all of them meet in the same house (they need to be in that house exactly in the same time).

Unfortunately, worms have not foreseen that it may take a long period of time to meet if they apply this method of movement. Sometimes it is even impossible to meet. That is why worms asked you for help with verifying whether their meeting can be arranged and if so, how long it will take to meet in the best case.

Write a program which:

• reads the description of the Mysterious Land of Worms from the standard input,
• checks whether the worms can meet and if so, how long it will take in the best case,
• writes the answer to the standard output.

입력

The first line of the standard input contains two integers n and m (2 ≤ n ≤ 50 000, 1 ≤ m ≤ 50 000), separated with a single space and denoting accordingly the number of houses and the number of paths in the Mysterious Land of Worms. Houses are numbered with natural numbers ranging from 1 to n. Following m lines contain descriptions of paths. Each of them consists of two integers a and b (1 ≤ a, bn), separated with a single space and denoting numbers of houses connected with a given path. Description of paths is followed by a line containing one integer k (2 ≤ kn), denoting the number of worms living in the Mysterious Land of Worms. Each of the following k lines contains one integer d (1 ≤ dn) denoting the house where the k-th worm lives.

출력

The first and only line of standard output should contain only one word NIE (i.e. no in Polish), if worms cannot meet while moving according to the rules, or one integer equal to the number of hours required by all worms to get to the meeting place.

예제 입력 1

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


예제 출력 1

1