Array Division
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Zhongli gives you two arrays a and b of length n. He asks you to divide into k continuous subarrays(a division for index), each index i belongs to exactly one subarray, and for these k continuous subarrays you divided, each meets the condition .
Formally, you should find k pairs satisfying following conditions:
  • for all
  • for all
  • for all
You should find the maximum k.

输入描述:

The first line contains a single integer  --- the number of test cases.
The first line of each test case contains a single integer --- the length of two arrays.
The second line of each test case contains n integers --- the array a.
The third line of each test case contains n integers --- the array b.
It is guaranteed that over all test cases.

输出描述:

For each test case, output a single integer in a line --- the maximum k, output -1 if there is no valid way to divide the two arrays.
示例1

输入

复制
2
5
1 2 3 4 5
2 2 2 2 2
3
1 2 2
2 2 2

输出

复制
3
-1