There are heroes and monsters. The heroes and monsters are numbered with integers from to . The strength of the -th hero is equal to a_i, and the strength of the -th monster is equal to b_i. It is guaranteed that all values a_1, a_2, \ldots, a_n, b_1, b_2, \ldots, b_n are pairwise distinct.
There will be a total of battles. In each battle, exactly one hero and exactly one monster will participate, with each hero and each monster participating in exactly one battle. Let the battle involve the hero with number and the monster with number . If a_i>b_j, then the hero with number will be happy, otherwise, he will be sad.
Let ans_k be the number of different sets of heroes of size , such that there is a distribution of battles where all heroes in will be happy and all other heroes will be sad.
Given queries of the form , . For each query, find (\sum\limits_{i=l}^{r} ans_i) \mod 998244353.
The first line contains a single integer (1 \leq n \leq 5 \cdot 10^3) — the number of battles that will take place.
The second line contains integers a_1, a_2, \ldots, a_n (1 \leq a_i \leq 2 \cdot n) — the strengths of the heroes.
The third line contains integers b_1, b_2, \ldots, b_n (1 \leq b_i \leq 2 \cdot n) — the strengths of the monsters.
It is guaranteed that all values a_1, a_2, \ldots, a_n, b_1, b_2, \ldots, b_n are pairwise distinct.
The fourth line contains a single integer (1 \leq q \leq n+1) — the number of queries.
The next lines contain two integers each, and (0 \leq l \leq r \leq n) — the parameters of the corresponding query.
It is guaranteed that all values a_1, a_2, \ldots, a_n, b_1, b_2, \ldots, b_n are pairwise distinct.
For each query, output a single integer — the required value (\sum\limits_{i=l}^{r} ans_i) \mod 998244353.
Example 1
The image below shows the heroes and monsters of the first example. The heroes are at the top, and the monsters are at the bottom. The number inside the square represents the strength of the corresponding hero or monster.

In the example, there are three possible sets of happy heroes: \{1,2,3\}, , and . Below are three possible distributions of battles in which the corresponding sets of heroes will be happy. Note that there may be multiple distributions of battles where the same set of heroes will be happy.

( points): a_i < b_j for 1 \leq i,j \leq n;
( points): q = 1, l = 1, r = 1;
( points): a_i = 2 \cdot i - 1, b_i = 2 \cdot i for 1 \leq i \leq n;
( points): n \leq 500, q = 1, l = 0, r = n;
( points): q = 1, l = 0, r = n;
( points): q = 1, l=r;
( points): n \leq 500;
( points): without additional restrictions.