Maximum Distance

No attempts yetTime limit1sMemory limit128 MB

Problem

Consider two non-increasing integer sequences $X[0..n-1]$ and $Y[0..n-1]$, where $X[i] \ge X[i+1]$ and $Y[i] \ge Y[i+1]$ for all $0 \le i < n-1$.

The distance $d(X[i], Y[j])$ between two elements $X[i]$ and $Y[j]$ is $j - i$ if $j \ge i$ and $Y[j] \ge X[i]$, and $0$ otherwise.

The distance between the sequences $X$ and $Y$ is

$$d(X, Y) = \max{, d(X[i], Y[j]) \mid 0 \le i < n,\ 0 \le j < n ,}.$$

For example, for the sequences $X$ and $Y$ shown below, the maximum is attained at $i = 2$ and $j = 7$, so $d(X, Y) = d(X[2], Y[7]) = 5$.

Input

The first line contains the number of test cases $T$. Each test case consists of three lines: the first line contains the sequence length $n$ ($0 < n < 1000$); the second line contains the $n$ elements of sequence $X$ separated by spaces; the third line contains the $n$ elements of sequence $Y$ separated by spaces. Both sequences are non-increasing and have equal length.

Output

For each test case, print a single line The maximum distance is d, where $d$ is the value of $d(X, Y)$. Separate the output of consecutive test cases with one blank line.