문제
Farmer John is planning to build
Farmer John's
Please determine whether each friend will be happy after visiting.
SCORING:
Test cases 2-5 satisfy
N\le 10^3, M\le 2\cdot 10^3.
Problem credits: Spencer Compton
입력
The first line contains the two integers
The second line contains a string of length
The next
The next
출력
Print a binary string of length
예제1
5 5
HHGHG
1 2
2 3
2 4
1 5
1 4 H
1 4 G
1 3 G
1 3 H
5 5 H
10110
Here, the path from farm 1 and farm 4 involves farms 1, 2, and 4. All of these contain Holsteins, so the first friend will be satisfied while the second one will not.