import sequtils,strutils var N , Q : int A : seq[int] B : seq[int] dp : array[2, array[6002, int64]] modnum : int64 = 998244353 (N, Q) = stdin.readline.split.map(parseInt) A = stdin.readline.split.map(parseInt) B = stdin.readline.split.map(parseInt) dp[0][0] = A[0] - 1 dp[0][1] = 1 for i in 0 .. (N - 2): for j in 0 .. (i + 1): dp[1][j + 1] += dp[0][j] dp[1][j] += (A[i + 1] - 1).int64 * dp[0][j] dp[1][j + 1] = dp[1][j + 1] mod modnum dp[1][j] = dp[1][j] mod modnum dp[0] = dp[1] for j in 0 .. (i + 2): dp[1][j] = 0 for b in B: echo dp[0][b]