import math from collections import Counter N,K = map(int,input().split()) A = list(map(int,input().split())) mod = 998244353 def md(n): lower_divisors , upper_divisors = [], [] i = 1 while i*i <= n: if n % i == 0: lower_divisors.append(i) if i != n // i: upper_divisors.append(n//i) i += 1 return lower_divisors + upper_divisors[::-1] class combination(): def __init__(self,N,p): self.fact = [1, 1] # fact[n] = (n! mod p) self.factinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p) self.inv = [0, 1] # factinv 計算用 self.p = p for i in range(2, N + 1): self.fact.append((self.fact[-1] * i) % p) self.inv.append((-self.inv[p % i] * (p // i)) % p) self.factinv.append((self.factinv[-1] * self.inv[-1]) % p) def cmb(self,n, r): if (r < 0) or (n < r): return 0 r = min(r, n - r) return self.fact[n] * self.factinv[r] * self.factinv[n-r] % self.p C = combination(3*10**5,mod) P = md(K) n = len(P) P.sort() inv = {p:i for i,p in enumerate(P)} A = [math.gcd(a,K) for a in A] T = Counter(A) N = len(T) dp = [[0]*n for _ in range(len(T)+1)] dp[0][0] = 1 idx = 0 for k,v in T.items(): for j in range(n-1,-1,-1): p = P[j] res = 1 for _ in range(v,-1,-1): jdx = inv[math.gcd(p*res,K)] dp[idx+1][jdx] = (dp[idx+1][jdx] + dp[idx][inv[p]]*C.cmb(v,_))%mod res = math.gcd(res*k,K) idx += 1 print(dp[-1][-1])