Your are given a Tree, a connected undirected graph consisting of N nodes, N-1 undirected edges and no cycles. Nodes are numbered from 1 to N.
A simple path between two nodes in a tree is a path between the two nodes consisting of no repeating nodes.
More formally, Simple path between two nodes a and b is a sequence of nodes V1 V2, ..., Vm such that
For any pair of nodes in a tree, this path is unique.
You are given M pair of nodes by means of two arrays L and R where (Li, Ri) represents the ith pair of nodes. Each pair represents a simple path between its nodes.
For each edge,report whether it is a part of at least one of the given simple paths or not.
Input:
First line consists of two space separated integers, N and M, where N represent the number of nodes, and M represent the number of simple paths.
Next N-1 lines consist of two space separated integers each, representing two nodes connected by an edge.
Next line consists of M space separated integers, representing array L.
Next line consists of M space separated integers, representing array R.
Constraints:
2 ≤ N ≤ 105
1 ≤ M ≤ 106
1 ≤ Li, Ri ≤ N
The edges are guaranteed to form a valid tree.
Output:
For each edge, in the same order as they were received in input, output
1, if it is a part of at least one of the given simple paths
or 0, otherwise.
For each edge, output answer in a new line.
The first simple path is represent by pair (4, 7). Edges in blue color represent this path.
The second simple path is represented by (3,7). Edges in green color represent this path.
Only edges (4,5) and (4,6) are not a part of any simple path.