# Arrange

Time Limit: 8000/4000 MS (Java/Others)

Memory Limit: 262144/262144 K (Java/Others)

## Description

Accidentally, Cupid, god of desire has hurt himself with his own dart and fallen in love with Psyche.

This has drawn the fury of his mother, Venus. The goddess then throws before Psyche a great mass of mixed crops.

There are $n$ heaps of crops in total, numbered from $1$ to $n$.

Psyche needs to arrange them in a certain order, assume crops on the $i$-th position is $A_i$.

She is given some information about the final order of the crops:

1. the minimum value of $A_1, A_2, ..., A_i$ is $B_i$.

2. the maximum value of $A_1, A_2, ..., A_i$ is $C_i$.

She wants to know the number of valid permutations. As this number can be large, output it modulo $998244353$.

Note that if there is no valid permutation, the answer is $0$.

## Input

The first line of input contains an integer $T$ $(1 \le T \le 15)$, which denotes the number of testcases.

For each test case, the first line of input contains single integer $n$ $(1 \le n \le 10 ^ 5)$.

The second line contains $n$ integers, the $i$-th integer denotes $B_i$ $(1 \le B_i \le n)$.

The third line contains $n$ integers, the $i$-th integer denotes $C_i$ $(1 \le C_i \le n)$.

## Output

For each testcase, print the number of valid permutations modulo $998244353$.

## Sample Input

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

## Sample Output

1
0

Hint
In the first example, there is only one valid permutation (2,1,3) .

In the second example, it is obvious that there is no valid permutation.


wange2014

## Source

BestCoder 2nd Anniversary