Given sequence

of length

and sequence

of length

, find the length of the longest common subsequence of

and

.
输入描述:
There are multiple test cases. The first line of input contains an integer
(
), the number of test cases.
For each test case:
The only line contains
integers,
,
,
,
,
,
,
(
,
,
,
,
,
).
is the length of
,
is the length of
.
To avoid large input, you should generate the sequences as follows:
For each
,
,
,
in order, update
to
, and then set
to
. And then, for each
,
,
,
in order, update
to
, and then set
to
.
It is guaranteed that the sum of
and the sum of
over all test cases does not exceed
.
输出描述:
For each test case:
Output an integer -- the length of the longest common subsequence of
and
, in one line.