from math import e class Combination: def __init__(self, MX=10**6, MOD=998244353): self.MX = MX self.MOD = MOD self.fact = [1] * (MX + 1) self.inv = [1] * (MX + 1) self.f_inv = [1] * (MX + 1) for i in range(2, MX + 1): self.fact[i] = (self.fact[i - 1] * i) % self.MOD self.inv[i] = ( - (self.MOD // i) * (self.inv[self.MOD % i])) % self.MOD self.f_inv[i] = (self.f_inv[i - 1] * self.inv[i]) % self.MOD def invs(self, n): if n <= self.MX: return self.inv[n] else: return pow(n, self.MOD - 2, self.MOD) def p(self, n, r): if r > n or r < 0: return 0 return (self.fact[n] * self.f_inv[r]) % self.MOD def c(self, n, r): if r > n or r < 0: return 0 return (self.fact[n] * self.f_inv[r] * self.f_inv[n - r]) % self.MOD com = Combination() def solve(): MOD = 998244353 N, M = map(int, input().split()) A = list(map(int, input().split())) dic = dict() for i in range(N): if N - A[i] not in dic: dic[N - A[i]] = 0 dic[N - A[i]] += 1 ls = list(dic.keys()) ls.sort() lsum = 0 rsum = 0 L, R = [], [] ans = 1 for i in range(len(ls)): now = ls[i] j = now - lsum k = now - rsum if lsum + dic[now] == now: L.append(dic[now]) lsum = now if rsum + dic[now] == now and i != len(ls) - 1: ans *= 2 ans %= MOD elif rsum + dic[now] == now: R.append(dic[now]) rsum = now elif j + k == dic[now] and j > 0 and k > 0: lsum = now rsum = now L.append(j) R.append(k) ans *= com.c(dic[now], j) ans %= MOD else: print(0) return ans *= com.c(M, len(L) + len(R)) ans %= MOD print(ans) return T = int(input()) for _ in range(T): solve()