#include #include template std::ostream &operator<<(std::ostream &os, const atcoder::static_modint &mint) { os << mint.val(); return os; } int main() { using namespace std; using modint = atcoder::static_modint<998244353>; unsigned N, M, K; cin >> N >> M >> K; vector S(N); for (auto &&s : S) { cin >> s; --s; } vector> cards(M); for (auto &&[a, _] : cards) cin >> a; for (auto &&[_, b] : cards) cin >> b; vector dp(M + 1, vector(K + 1)); dp.back()[0] = 1; for (const auto &s : S) { vector prev(dp.back()); const auto &[a, b]{cards[s]}; for (unsigned i{}; i + a <= K; ++i) prev[i + a] += dp.back()[i]; for (unsigned i{}; i + b <= K; ++i) prev[i + b] += dp.back()[i]; for (unsigned i{}; i <= K; ++i) prev[i] -= dp[s][i]; ranges::fill(dp[s], modint{}); for (unsigned i{}; i + a <= K; ++i) dp[s][i + a] += dp.back()[i]; for (unsigned i{}; i + b <= K; ++i) dp[s][i + b] += dp.back()[i]; swap(dp.back(), prev); } cout << dp.back().back().val() << endl; return 0; }