#P1783E. Game of the Year

    ID: 316 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 8 Uploaded By: Tags>brute forcedata structuresmathnumber theory*2300

Game of the Year

Description

Monocarp and Polycarp are playing a computer game. This game features nn bosses for the playing to kill, numbered from 11 to nn.

They will fight each boss the following way:

  • Monocarp makes kk attempts to kill the boss;
  • Polycarp makes kk attempts to kill the boss;
  • Monocarp makes kk attempts to kill the boss;
  • Polycarp makes kk attempts to kill the boss;
  • ...

Monocarp kills the ii-th boss on his aia_i-th attempt. Polycarp kills the ii-th boss on his bib_i-th attempt. After one of them kills the ii-th boss, they move on to the (i+1)(i+1)-st boss. The attempt counters reset for both of them. Once one of them kills the nn-th boss, the game ends.

Find all values of kk from 11 to nn such that Monocarp kills all bosses.

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of testcases.

The first line of each testcase contains a single integer nn (1n21051 \le n \le 2 \cdot 10^5) — the number of bosses.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ain1 \le a_i \le n) — the index of attempt Monocarp kills each boss on.

The third line contains nn integers b1,b2,,bnb_1, b_2, \dots, b_n (1bin1 \le b_i \le n) — the index of attempt Polycarp kills each boss on.

The sum of nn over all testcases doesn't exceed 21052 \cdot 10^5.

For each testcase, print two lines. The first line should contain a single integer cnt\mathit{cnt} — the number of values of kk from 11 to nn such that Monocarp kills all bosses. The second line should contain cnt\mathit{cnt} distinct integers — the values of kk themselves.

Input

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of testcases.

The first line of each testcase contains a single integer nn (1n21051 \le n \le 2 \cdot 10^5) — the number of bosses.

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ain1 \le a_i \le n) — the index of attempt Monocarp kills each boss on.

The third line contains nn integers b1,b2,,bnb_1, b_2, \dots, b_n (1bin1 \le b_i \le n) — the index of attempt Polycarp kills each boss on.

The sum of nn over all testcases doesn't exceed 21052 \cdot 10^5.

Output

For each testcase, print two lines. The first line should contain a single integer cnt\mathit{cnt} — the number of values of kk from 11 to nn such that Monocarp kills all bosses. The second line should contain cnt\mathit{cnt} distinct integers — the values of kk themselves.

Sample Input 1

3
3
1 1 1
2 3 1
1
1
1
4
1 4 3 2
3 3 4 1

Sample Output 1

3
1 2 3 
1
1 
2
2 4

Note

Consider the last testcase of the example.

Let k=1k = 1. First, Monocarp makes one attempt to kill the first boss. It's successful, since a1=1a_1 = 1. Then, Monocarp makes one attempt to kill the second boss. It's unsuccessful, since a2>1a_2 > 1. So, Polycarp makes an attempt then. It's also unsuccessful, since b2>1b_2 > 1. Then, Monocarp makes another attempt. It's still unsuccessful, since a2>2a_2 > 2. This goes on until Polycarp finally kills the boss on his third attempt. Monocarp didn't kill this boss, thus, k=1k = 1 isn't the answer.

Let k=2k = 2. Monocarp still kills the first boss on his first attempt. Then, he makes two unsuccessful attempts for the second boss. Then, Polycarp makes two unsuccessful attempts. Then, Monocarp makes two more attempts and kills the boss on his fourth attempt. The third boss is similar. First, two unsuccessful attempts by Monocarp. Then, two unsuccessful attempts by Polycarp. Then, Monocarp has two more attempts, but even his first one is successful, since a3=3a_3 = 3. The fourth boss is also killed by Monocarp. Thus, k=2k = 2 is the answer.