#P7639. [2018年杭电多校]Rikka with Time Complexity
[2018年杭电多校]Rikka with Time Complexity
Rikka with Time Complexity
Problem Description
Input
The first line contains a single number , the number of testcases. For each testcase, the first line contains two integers , the length of and . The second line contains integers and the third line contains integers , which describe and .
Output
For each testcase, output a single line with a single integer, the answer.
Sample Input
3
1 1
1
2
2 2
1 2
2 1
1 3
1
1000000000 3 3
Sample Output
1
-1
-1
Source
2018 Multi-University Training Contest 9