Question
Equal Binary Transitions

You are given a tree with KaTeX can only parse string typed expression nodes numbered from KaTeX can only parse string typed expression to KaTeX can only parse string typed expression.

Each node contains a binary value — either KaTeX can only parse string typed expression or KaTeX can only parse string typed expression.

For every query, you are given two nodes KaTeX can only parse string typed expression and KaTeX can only parse string typed expression. Consider the binary string formed by writing the values of all nodes on the simple path from KaTeX can only parse string typed expression to KaTeX can only parse string typed expression in order.

Your task is to determine whether the number of occurrences of substring KaTeX can only parse string typed expression is equal to the number of occurrences of substring KaTeX can only parse string typed expression in that path string.

Input
The first line contains a single integer KaTeX can only parse string typed expression — the number of nodes in the tree.

The second line contains a binary string of length KaTeX can only parse string typed expression, where the KaTeX can only parse string typed expression character represents the value of node KaTeX can only parse string typed expression.

The next KaTeX can only parse string typed expression lines each contain two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — representing an edge between nodes KaTeX can only parse string typed expression and KaTeX can only parse string typed expression.

The next line contains a single integer KaTeX can only parse string typed expression — the number of queries.

Each of the next KaTeX can only parse string typed expression lines contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression.
Output
For each query, print:

KaTeX can only parse string typed expression if the number of KaTeX can only parse string typed expression substrings is equal to the number of KaTeX can only parse string typed expression substrings on the path.
KaTeX can only parse string typed expression otherwise.
Example
Input
5
01011
1 2
1 3
3 4
3 5
3
2 4
1 4
2 5

Output
YES
NO
YES

Online