#include namespace nono { constexpr long long mod = 998244353; void solve() { int n, k; std::cin >> n >> k; std::vector c(n), d(n); for (int i = 0; i < n; i++) std::cin >> c[i]; for (int i = 0; i < n; i++) std::cin >> d[i]; const long long inf = 1e18; std::vector dp(k + 1, -inf); dp[0] = 0; for (int i = 0; i < n; i++) { for (int j = 0; j <= k; j++) { // use if (dp[j] != -inf and j + c[i] <= k) { dp[j + c[i]] = std::max(dp[j + c[i]], dp[j] + d[i]); } } } long long happy = *std::max_element(dp.begin(), dp.end()); int max_i = -1; for (int i = 0; i <= k; i++) { if (dp[i] == happy) { max_i = i; break; } } // std::cout << happy << std::endl; std::vector ans(max_i + 1); ans[0] = 1; for (int i = 0; i < max_i; i++) { for (int j = 0; j < n; j++) { if (i + c[j] <= max_i and dp[i] + d[j] == dp[i + c[j]]) { ans[i + c[j]] += ans[i]; ans[i + c[j]] %= mod; } } } std::cout << happy << std::endl; std::cout << ans[max_i] << std::endl; } } // namespace nono int main() { std::cin.tie(0)->sync_with_stdio(0); std::cout << std::fixed << std::setprecision(15); int t = 1; // std::cin >> t; while (t--) nono::solve(); }