
Input:
'N' = 5, ‘K’ = 3
‘ARR’ = [-1, 0, 0, 1, 2]
‘LOCK’ = [0, 0, 1, 0, 0]
Output: ‘1’

In the above tree in the simple path from node ‘4’ to root ‘1,’ the nodes encountered are [0, 1, 3], and no node from the set is locked. Hence node ‘3’ can be locked.
The first line will contain the integer 'T', the number of test cases. For each test case
The first line of each test case contains two integers ‘N’, and ‘K’.
The second line of each test case contains ‘N’ integers denoting the parent of node ‘i’.
The third line of each test case contains ‘N’ integers denoting elements of array ‘LOCK’.
For each test case, print ‘1’ or ’0’, denoting whether the node can be locked.
You don't need to print anything. It has already been taken care of. Just implement the given function.
1 <= 'T' <= 10
1 <= 'N' <= 10^5
0 <= ‘K’ <= ‘N-1’
0 <= ‘PAR[i]’ <= ‘N-1’
0 <= ‘LOCK[i]’ <= 1
Time Limit: 1 sec
Approach:
Algorithm :