MOD = 998244353 N, M, K = map(int, input().split()) S = list(map(lambda x: x - 1, map(int, input().split()))) A = list(map(int, input().split())) B = list(map(int, input().split())) prev = dict() ac = [[0] * (K + 1) for _ in range(N + 1)] dp = [[0] * (K + 1) for _ in range(N)] for i in range(N): p = 0 a = A[S[i]] b = B[S[i]] if S[i] in prev: p = prev[S[i]] else: dp[i][a] += 1 dp[i][b] += 1 prev[S[i]] = i for j in range(K + 1): if j + a <= K: dp[i][j + a] += ac[i][j] - ac[p][j] dp[i][j + a] %= MOD if j + b <= K: dp[i][j + b] += ac[i][j] - ac[p][j] dp[i][j + b] %= MOD for j in range(K + 1): ac[i + 1][j] = ac[i][j] + dp[i][j] ac[i + 1][j] %= MOD # for i in range(N + 1): # print(ac[i]) print(ac[-1][K])