문제
Farmer John is planning to build
Farmer John's
Please determine whether each friend will be happy after visiting.
SCORING:
Test case 2 is the second example case below.
Test case 3 satisfies
N\le 10^3, M\le 2\cdot 10^3 .Test cases 4-7 satisfy
C_i\le 10 (C_i defined below).
Problem credits: Spencer Compton
입력
The first line contains two integer
The second line contains
The next
The next
출력
Print a binary string of length
예제1
5 5
1 1 2 1 2
1 2
2 3
2 4
1 5
1 4 1
1 4 2
1 3 2
1 3 1
5 5 1
10110
In this example, the path from 1 and 4 involves farms 1, 2, and 4. All of these contain cows of type 1, so the first friend will be satisfied while the second one will not.
예제2
6 4
1 2 3 3 3 3
1 2
2 3
3 4
2 5
5 6
4 6 1
4 6 2
4 6 3
4 6 4
0110