#include #include using namespace std; #include using mint = atcoder::modint998244353; int main() { cin.tie(nullptr)->sync_with_stdio(false); int N, M, K; cin >> N >> M >> K; vector S(N), A(M), B(M); for (auto &x : S) cin >> x, --x; for (auto &x : A) cin >> x; for (auto &x : B) cin >> x; for (int i = 0; i < M; ++i) { if (A.at(i) > B.at(i)) std::swap(A.at(i), B.at(i)); } vector dpall(K + 1); dpall.at(0) = 1; vector dp(M, vector(K + 1)); for (const int s : S) { const int a = A.at(s), b = B.at(s); for (int k = K - a; k >= 0; --k) { dpall.at(k + a) += dpall.at(k) + dp.at(s).at(k); if (k + b <= K) dpall.at(k + b) += dpall.at(k) + dp.at(s).at(k); dp.at(s).at(k) = -dpall.at(k); } } cout << dpall.back().val() << '\n'; }