


Case 1:
Suppose given array of distinct integers ‘ARR' = [10, 35] and array of integers array ‘PIECES' = [ [35], [10] ]. So, we return ‘True’ as we can form such array-like first we concatenate [10], then [35] hence it is possible to make ‘ARR’ from ‘PIECES’.
Case 2:
Suppose if the array of distinct integers ‘ARR' = [ 2, 1, 3 ] and an array of integers array ‘PIECES' = [ [ 1, 2 ], [ 3 ] ]. So we return ‘False’ as we cant form such an array because we can’t change the order of [ 1, 2 ].
The first line of input contains a ‘T’ number of test cases.
The first line of each test case contains an integer ‘N’, which represents the size of the array ‘ARR’.
The second line of each test case contains the ‘N’ space-separated integer of array ‘ARR’.
The third line of each test case contains an integer ‘M’ denoting the number of rows in array ‘PIECES’. Then, ‘M’ lines follow.
Each line contains an integer ‘R' denoting the number of columns in that row and ‘R’ space-separated integers denoting the values of the row.
For each test case, print in a line ‘True’ if it is possible to form else print ‘False’.
Print the output of each test case in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= M <= N <= 1000
1 <= R <= 1000
1 <= ARR[i], PIECES[i][j] <=100
Time Limit: 1 second
Algorithm:
Algorithm: