P = 998244353 n, x = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for j in range(n + 1): for k in range(n + 1 - j): ans += A[j + k] * B[j] * C[k] * pow(x, (j + k) * j * k) print(ans % P)