Chiaki has two sequences a_1,a_2,…,a_n and b_1,b_2,…,b_m. She would like to find their longest common subsequence c_1,c_2,…,c_k such that c_1≤c_2≤…≤c_k.
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains two integers n and m (1≤n,m≤106): the lengths of two sequences.
The second line contains n integers a_1,a_2,…,a_n (1≤a_i≤3).
The third line contains m integers b_1,b_2,…,b_m (1≤b_i≤3).
It is guaranteed that the sum of maxn,m in all test cases does not exceed 106.
For each test case, output a single integer k: the length of the longest common subsequence c_1,c_2,…,c_k such that c_1≤c_2≤…≤c_k.