We start with a change a1,a2,… ,an and with a vacant exhibit b. We apply the accompanying activity k occasions. On the I-th cycle, we select a list ti (1≤ti≤n−i+1), eliminate ati from the exhibit, and affix one of the numbers ati−1 or ati+1 (if ti−1 or ti+1 are inside the cluster limits) to the right finish of the exhibit b. Then, at that point, we move components ati
Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.
We start with a change a1,a2,… ,an and with a vacant exhibit b. We apply the accompanying activity k occasions.
On the I-th cycle, we select a list ti (1≤ti≤n−i+1), eliminate ati from the exhibit, and affix one of the numbers ati−1 or ati+1 (if ti−1 or ti+1 are inside the cluster limits) to the right finish of the exhibit b. Then, at that point, we move components ati+1,… ,a to one side to occupy in the unfilled space.
You are given the underlying change a1,a2,… ,an and the subsequent cluster b1,b2,… ,bk. All components of an exhibit b are particular. Compute the number of potential groupings of lists t1,t2,… ,tk modulo 998244353.
Input
Each test contains numerous experiments. The principal line contains an integer t (1≤t≤100000), indicating the number of experiments, trailed by a portrayal of the experiments.
The main line of each experiment contains two integers n,k (1≤k<n≤200000): sizes of clusters an and b.
The second line of each experiment contains n integers a1,a2,… ,an (1≤
The third line of each experiment contains k integers b1,b2,… ,bk (1≤bi≤n): components of b. All components of b are particular.
The amount of all n among all experiments is ensured to not surpass 200000.
Output
For each experiment print one integer: the number of potential groupings modulo 998244353.
Step by step
Solved in 3 steps with 1 images