We start with a permutation $a_1, a_2, \ldots, a_n$ and with an empty array $b$. We apply the following operation $k$ times.

On the $i$-th iteration, we select an index $t_i$ ($1 \le t_i \le n-i+1$), remove $a_{t_i}$ from the array, and append one of the numbers $a_{t_i-1}$ or $a_{t_i+1}$ (if $t_i-1$ or $t_i+1$ are within the array bounds) to the right end of the array $b$. Then we move elements $a_{t_i+1}, \ldots, a_n$ to the left in order to fill in the empty space.

You are given the initial permutation $a_1, a_2, \ldots, a_n$ and the resulting array $b_1, b_2, \ldots, b_k$. All elements of an array $b$ are distinct. Calculate the number of possible sequences of indices $t_1, t_2, \ldots, t_k$ modulo $998\,244\,353$.


-----Input-----

Each test contains multiple test cases. The first line contains an integer $t$ ($1 \le t \le 100\,000$), denoting the number of test cases, followed by a description of the test cases.

The first line of each test case contains two integers $n, k$ ($1 \le k < n \le 200\,000$): sizes of arrays $a$ and $b$.

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le n$): elements of $a$. All elements of $a$ are distinct.

The third line of each test case contains $k$ integers $b_1, b_2, \ldots, b_k$ ($1 \le b_i \le n$): elements of $b$. All elements of $b$ are distinct.

The sum of all $n$ among all test cases is guaranteed to not exceed $200\,000$.


-----Output-----

For each test case print one integer: the number of possible sequences modulo $998\,244\,353$.


-----Example-----
Input
3
5 3
1 2 3 4 5
3 2 5
4 3
4 3 2 1
4 3 1
7 4
1 4 7 3 6 2 5
3 2 4 5

Output
2
0
4



-----Note-----

$\require{cancel}$

Let's denote as $a_1 a_2 \ldots \cancel{a_i} \underline{a_{i+1}} \ldots a_n \rightarrow a_1 a_2 \ldots a_{i-1} a_{i+1} \ldots a_{n-1}$ an operation over an element with index $i$: removal of element $a_i$ from array $a$ and appending element $a_{i+1}$ to array $b$.

In the first example test, the following two options can be used to produce the given array $b$:  $1 2 \underline{3} \cancel{4} 5 \rightarrow 1 \underline{2} \cancel{3} 5 \rightarrow 1 \cancel{2} \underline{5} \rightarrow 1 2$; $(t_1, t_2, t_3) = (4, 3, 2)$;  $1 2 \underline{3} \cancel{4} 5 \rightarrow \cancel{1} \underline{2} 3 5 \rightarrow 2 \cancel{3} \underline{5} \rightarrow 1 5$; $(t_1, t_2, t_3) = (4, 1, 2)$. 

In the second example test, it is impossible to achieve the given array no matter the operations used. That's because, on the first application, we removed the element next to $4$, namely number $3$, which means that it couldn't be added to array $b$ on the second step.

In the third example test, there are four options to achieve the given array $b$:  $1 4 \cancel{7} \underline{3} 6 2 5 \rightarrow 1 4 3 \cancel{6} \underline{2} 5 \rightarrow \cancel{1} \underline{4} 3 2 5 \rightarrow 4 3 \cancel{2} \underline{5} \rightarrow 4 3 5$; $1 4 \cancel{7} \underline{3} 6 2 5 \rightarrow 1 4 3 \cancel{6} \underline{2} 5 \rightarrow 1 \underline{4} \cancel{3} 2 5 \rightarrow 1 4 \cancel{2} \underline{5} \rightarrow 1 4 5$; $1 4 7 \underline{3} \cancel{6} 2 5 \rightarrow 1 4 7 \cancel{3} \underline{2} 5 \rightarrow \cancel{1} \underline{4} 7 2 5 \rightarrow 4 7 \cancel{2} \underline{5} \rightarrow 4 7 5$; $1 4 7 \underline{3} \cancel{6} 2 5 \rightarrow 1 4 7 \cancel{3} \underline{2} 5 \rightarrow 1 \underline{4} \cancel{7} 2 5 \rightarrow 1 4 \cancel{2} \underline{5} \rightarrow 1 4 5$;

Difficulty: competition

Starter code:

Solutions:
import sys
readline = sys.stdin.readline

T = int(readline())
MOD =  998244353
Ans = [None]*T
for qu in range(T):
    N, K = map(int, readline().split())
    A = [0] + list(map(int, readline().split())) + [0]
    B = list(map(int, readline().split()))
    C = [None]*(N+1)
    for i in range(1, N+1):
        C[A[i]] = i
    ans = 1
    for b in B[::-1]:
        bi = C[b]
        res = 0
        if A[bi-1]:
            res += 1
        if A[bi+1]:
            res += 1
        A[bi] = 0
        ans = ans*res%MOD
    Ans[qu] = ans
print('\n'.join(map(str, Ans))) 

import sys
input = sys.stdin.readline

mod=998244353

t=int(input())
for tests in range(t):
    n,k=list(map(int,input().split()))
    A=list(map(int,input().split()))
    B=list(map(int,input().split()))

    X=[-1]*(n+1)
    for i in range(n):
        X[A[i]]=i

    for i in range(k):
        B[i]=X[B[i]]

    Y=[0]*n
    for b in B:
        Y[b]=1
        
    Y.append(1)

    #print(Y)
    #print(B)

    ANS=0
    for b in B:
        #print(b,Y)
        if Y[b-1]==1 and Y[b+1]==1:
            print(0)
            break

        elif Y[b-1]==0 and Y[b+1]==0:
            ANS+=1

        Y[b]=0

    else:
        print(pow(2,ANS,mod))

    


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    r = [0] * n
    for i in range(n):
        r[a[i] - 1] = i
    b = list(map(int, input().split()))
    d = [0] * n
    for i in range(k):
        d[b[i] - 1] = 1
    cnt = 0
    for i in range(k):
        idx = r[b[i] - 1]
        t = 0
        if idx > 0 and d[a[idx - 1] - 1] == 0:
            t += 1
        if idx < n - 1 and d[a[idx + 1] - 1] == 0:
            t += 1
        if t == 0:
            print(0)
            break
        elif t == 2:
            cnt += 1
        d[b[i] - 1] = 0
    else:
        print(pow(2, cnt, 998244353))


import sys
from sys import stdin


tt = int(stdin.readline())
mod = 998244353

for loop in range(tt):

    n,k = map(int,stdin.readline().split())
    a = list(map(int,stdin.readline().split()))
    b = list(map(int,stdin.readline().split()))

    l = [None] * (n+1)
    r = [None] * (n+1)
    use = [True] * (n+1)
    for i in b:
        use[i] = False
    for i in range(n):
        if i != n-1:
            l[a[i]] = a[i+1]
        if i != 0:
            r[a[i]] = a[i-1]

    ans = 1
    for i in range(k):
        now = 0
        if l[b[i]] != None and use[l[b[i]]]:
            now += 1
        if r[b[i]] != None and use[r[b[i]]]:
            now += 1
        ans *= now
        ans %= mod

        if l[b[i]] != None:
            r[l[b[i]]] = r[b[i]]
        if r[b[i]] != None:
            l[r[b[i]]] = l[b[i]]

    print (ans % mod)