B. Sequence Duplication
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You're given an array $$$a$$$ of size $$$n$$$ and an array $$$b$$$ of size $$$m$$$.

Find the minimum $$$k$$$ such that $$$a$$$ is a subsequence$$$^\dagger$$$ of $$$dup(b, k)$$$. If there's no such $$$k$$$, output $$$-1$$$ instead.

Here $$$dup(b,k)=[b_1,b_2,\ldots,b_m,b_1,b_2,\ldots,b_m,\ldots]$$$($$$k$$$ times). More formally, $$$dup(b,k)$$$ is an array $$$x$$$ of length $$$m \cdot k$$$, where $$$x_i = b _{(i-1)\ mod\ m\ +\ 1}$$$ for all $$$1 \le i \le m \cdot k$$$.

$$$^\dagger$$$A subsequence of a sequence is a sequence that is formed by selecting zero or more elements from the original sequence while maintaining the relative order of the selected elements.

Input

The first line contains a single integer $$$t(1 \le t\le 10^4)$$$ — the number of test cases.

The first line of each test case contains two numbers $$$n,m(1 \le n,m\le 2\times10^5)$$$.

The second line of each test case contains $$$n$$$ numbers $$$a_1,a_2,\ldots,a_n(1 \le a_i\le max(n,m))$$$.

The third line of each test case contains $$$m$$$ numbers $$$b_1,b_2,\ldots,b_m(1 \le b_i\le max(n,m))$$$.

It is guaranteed that the sum of $$$n$$$ for all tests does not exceed $$$2\times 10^5$$$, and the sum of $$$m$$$ for all tests does not exceed $$$2\times 10^5$$$.

Output

For each test case, output the minimum $$$k$$$. If there's no suitable $$$k$$$, output $$$-1$$$ instead.

Example
Input
4
2 1
1 1
2
3 4
2 1 2
1 2 1 1
4 4
1 2 3 4
4 3 2 1
18 17
11 17 1 5 16 17 16 18 16 13 16 2 9 16 16 11 5 1
3 16 18 18 11 5 13 16 1 14 17 9 16 2 17 5 13
Output
-1
2
4
7