#include using namespace std; int main() { int N, K, m = 998244353; cin >> N >> K; vector C(N), D(N); vector> DP(K + 1, {-1e9, 0}); for (int &c : C) cin >> c; for (int &d : D) cin >> d; DP.at(0) = {0, 1}; for (int i = 0; i < K; i++) { for (int j = 0; j < N; j++) { if (i + C.at(j) > K) continue; if (DP.at(i).first + D.at(j) > DP.at(i + C.at(j)).first) DP.at(i + C.at(j)) = {DP.at(i).first + D.at(j), DP.at(i).second}; else if (DP.at(i).first + D.at(j) == DP.at(i + C.at(j)).first) DP.at(i + C.at(j)).second = (DP.at(i + C.at(j)).second + DP.at(i).second) % m; } } pair Ans = {-1, 0}; for (pair P : DP) { if (P.first > Ans.first) Ans = P; else if (P.first == Ans.first) Ans.second = (Ans.second + P.second) % m; } cout << Ans.first << endl << Ans.second << endl; }