1221#13089

1221

1 second
256 megabytes

For Python users, make sure to select PyPy3 / PyPy2 (depending on which version of Python you're using) instead of Python3 or Python2 when submitting.

You're given two arrays and of length (|a|=|b|=n). Your task is to count the number of valid index selections such that the three chosen values form a non-degenerate triangle. Different selections of indices are counted separately, even if they produce the same multiset of side lengths.

A triplet can be formed in one of the following ways:

A triangle with side lengths (x,y,z) is called non-degenerate if and only if the following conditions hold:

Input

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

For each test case: The first line contains a single integer (2 \le n \le 2000) — the length of arrays and .

The second line contains integers a_1,a_2,\dots,a_n (1 \le a_i \le 10^9) — the elements of array .

The third line contains integers b_1,b_2,\dots,b_n (1 \le b_i \le 10^9) — the elements of array .

It is guaranteed that the sum of over all test cases does not exceed .

Output

For each test case, output a single integer — the total number of valid triplets.

Examples

Example 1

Loading
Loading

Note

In the first test case , the only way to form a valid triplet

  • Pick x=a_1=2 , y=a_2=3 from array and z=b_1=4 from array

In the second test case , there are three ways to form a valid triplet

  • (2,3,2) Pick x=a_1=2 , y=a_2=3 from array and z=b_1=2 from array

  • (2,3,4) Pick x=a_1=2 , y=a_2=3 from array and z=b_2=4 from array

  • (2,4,3) Pick x=b_1=2 , y=b_2=4 from array and z=a_2=3 from array

In the third test case , there are six ways to form a valid triplet

  • Pick x=a_1=1 , y=a_2=1 from array and z=b_1=1 from array

  • Pick x=a_1=1 , y=a_3=1 from array and z=b_1=1 from array

  • Pick x=a_2=1 , y=a_3=1 from array and z=b_1=1 from array

  • Pick x=b_2=2 , y=b_3=2 from array and z=a_1=1 from array

  • Pick x=b_2=2 , y=b_3=2 from array and z=a_2=1 from array

  • Pick x=b_2=2 , y=b_3=2 from array and z=a_3=1 from array

Scoring

  1. Subtask ( points) : (1 \le \sum n \le 100)

  2. Subtask ( points) : (1 \le a_1,a_2,\ldots,a_n \le 10) and (1 \le b_1,b_2,\ldots,b_n \le 10).

  3. Subtask ( points) : No additional constraints