You are given an array of distinct integers and another array which is a permutation of array . Find the maximum number of segments array could be split such that within each segment, Array is a permutation of array .
INPUT FORMAT
The first line contains an integer, - denoting the number of test cases.
The first line of each test case contains two integers - denoting the length of the array .
The second line of each test case contains integers — elements of array .
The second line of each test case contains integers — elements of array which is a permutation of array .
OUTPUT FORMAT
For each test case, print the answer in a new line.
Constraints
, sum of across all test cases <=
Array is a permutation of array .
Test case 1: We split array into following 2 segments -
such that is permutation of and is permutation of .
Test case 2: There is no way to split, hence only 1 segment -
such that is permutation of .
Test case 3: We split array into following 3 segments-
such that is permutation of , is permutation of and is permutation of .