AT_arc220_b [ARC220B] Incomplete Shuffle
Description
You are given a positive integer $ N $ and integer sequences of length $ N $ : $ A=(A_1,A_2,\ldots,A_N) $ and $ B=(B_1,B_2,\ldots,B_N) $ .
You perform $ N-1 $ operations on $ A $ . The $ i $ -th operation $ (1\le i\le N-1) $ is as follows:
- Choose an integer $ j $ satisfying $ i < j \le N $ , and swap the values of $ A_i $ and $ A_j $ .
Find the maximum possible number of indices $ k $ $ (1\le k\le N) $ satisfying $ A_k=B_k $ after $ N-1 $ operations.
You are given $ T $ test cases; solve each of them.
Input Format
The input is given from Standard Input in the following format:
> $ T $ $ \text{case}_1 $ $ \text{case}_2 $ $ \vdots $ $ \text{case}_T $
Each test case is given in the following format:
> $ N $ $ A_1 $ $ A_2 $ $ \ldots $ $ A_N $ $ B_1 $ $ B_2 $ $ \ldots $ $ B_N $
Output Format
Output the answers for the test cases in order, separated by newlines.
Explanation/Hint
### Sample Explanation 1
Consider the first test case.
By performing the operations as follows, the number of indices $ k $ satisfying $ A_k=B_k $ after $ N-1 $ operations can be made $ 2 $ .
- When $ i=1 $ : choose $ j=2 $ . $ A=(1,1,2) $ .
- When $ i=2 $ : choose $ j=3 $ . $ A=(1,2,1) $ .
The number of indices $ k $ satisfying $ A_k=B_k $ after $ N-1 $ operations cannot be made greater than $ 2 $ , so output $ 2 $ on the first line.
### Constraints
- $ 1\le T\le 10^5 $
- $ 2\le N\le 3\times 10^5 $
- $ 1\le A_i,B_i\le N $
- The sum of $ N $ over all test cases is at most $ 3\times 10^5 $ .
- All input values are integers.