#include using namespace std; #include using namespace atcoder; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define REP(i, n) for (long long i = 1; i < (long long)(n); i++) typedef long long ll; using mint = modint; void mod(ll &a){ a %= 998244353; return; } int main() { ll n, m, k; cin >> n >> m >> k; vector s(n), a(m), b(m); rep(i, n) { cin >> s[i]; s[i]--; } rep(i, m) { cin >> a[i]; } rep(i, m) { cin >> b[i]; } vector> dp(n + 1, vector(k + 1, 0)); dp[0][0] = 1; vector> cum(n + 2, vector(k + 1, 0)); cum[1][0] = 1; vector idx(m, 0); rep(i, n) { rep(j, k + 1) { if (0 <= j - a[s[i]]) { dp[i + 1][j] += cum[i + 1][j - a[s[i]]] - cum[idx[s[i]]][j - a[s[i]]]; mod(dp[i+1][j]); } if (0 <= j - b[s[i]]) { dp[i + 1][j] += cum[i + 1][j - b[s[i]]] - cum[idx[s[i]]][j - b[s[i]]]; mod(dp[i+1][j]); } cum[i + 2][j] = cum[i + 1][j] + dp[i + 1][j]; mod(dp[i+1][j]); } idx[s[i]] = i + 1; } ll ans = 0; rep(i, n) { ans += dp[i + 1][k]; } mod(ans); cout << ans << endl; }