import sys from itertools import permutations input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) import random def cmb(n, r, mod): if ( r<0 or r>n ): return 0 return (g1[n] * g2[r] % mod) * g2[n-r] % mod mod = 998244353 N = 2*10**5 g1 = [1]*(N+1) g2 = [1]*(N+1) inverse = [1]*(N+1) for i in range( 2, N + 1 ): g1[i]=( ( g1[i-1] * i ) % mod ) inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod ) g2[i]=( (g2[i-1] * inverse[i]) % mod ) inverse[0]=0 for _ in range(int(input())): N,M = mi() A = li() A.sort() if N & 1 or A[0]!=N//2: k = N//2 if k < A[0]: print(0) continue small = [a for a in A if a <= k] if small[0]!=small[-1]: print(0) continue big = [a for a in A if k < a] dic = {a:0 for a in big} for a in big: dic[a] += 1 big = [(a,dic[a]) for a in dic] big.sort() L,R = 0,0 c = 0 res = 1 for a,t in big[::-1]: tmp_l = N-a-L tmp_r = N-a-R #print(tmp_l,tmp_r,t) if tmp_l == t and tmp_r == t: c += 1 res = 2 * res % mod L += t elif tmp_l == t or tmp_r == t: c += 1 L += t elif tmp_l+tmp_r == t and 0 < tmp_l and 0 < tmp_r: c += 2 L += tmp_l R += tmp_r res = res * cmb(t,tmp_l,mod) else: res = 0 c += 1 res = res * cmb(M,c,mod) % mod if max(L,R) == small[0]: print(res) else: print(0) continue else: dic = {a:0 for a in A} for a in A: dic[a] += 1 big = [(a,dic[a]) for a in dic] big.sort() L,R = 0,0 c = 0 res = 1 for a,t in big[::-1]: tmp_l = N-a-L tmp_r = N-a-R if tmp_l == t and tmp_r == t: c += 1 res = 2 * res % mod L += t elif tmp_l == t or tmp_r == t: c += 1 L += t elif tmp_l+tmp_r == t and 0 < tmp_l and 0 < tmp_r: c += 2 L += tmp_l R += tmp_r res = res * cmb(t,tmp_l,mod) else: res = 0 res = res * cmb(M,c,mod) % mod if L == N//2 and R == N//2: print(res) else: print(0) continue