Find Palindromes
You are given a tree T with N nodes and the tree rooted at node 1. Every node has a character C[i] assigned to it. You are given Q queries of the following format:
Query: u
You must find whether string S that is generated for node u is palindromic or not. String S for a node u is generated as follows:
S = Empty
makeString(u)
{
For all v = Child of u
makeString(v)
S += C[u];
}
Child of v should be traversed in order of increasing Node number
Input format
Output format
Print Q lines and in each line, print 1 if S is palindromic. Otherwise, print 0.
Note: Use fast I/O
1Example 1
For node 1, S = "bcbaa"
For node 2, S = "bcb"
Constraints
Limits and guarantees your solution can rely on.
1 ≤ N, Q ≤ 200000|C[i]| contains lowercase Latin Letters.