#include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; constexpr ll MOD = 998244353; int main(){ int n, k; cin >> n >> k; vector c(n), d(n); for(auto &it: c) cin >> it; for(auto &it: d) cin >> it; vector> dp(k+10, vector(k+10, -(1 << 30))); vector> cnt(k+10, vector(k+10, 0)); dp[0][0] = 0; cnt[0][0] = 1; for(int i = 0; i <= k; i++){ for(int j = 0; j <= k; j++){ if(cnt[i][j] == 0) continue; for(int l = 0; l < n; l++){ if(k < j+c[l]) continue; if(dp[i+1][j+c[l]] < dp[i][j]+d[l]){ dp[i+1][j+c[l]] = dp[i][j]+d[l]; cnt[i+1][j+c[l]] = cnt[i][j]; }else if(dp[i+1][j+c[l]] == dp[i][j]+d[l]){ cnt[i+1][j+c[l]] = (cnt[i+1][j+c[l]]+cnt[i][j])%MOD; } } } } int maxc = 0; for(int i = 0; i <= k; i++){ for(int j = 0; j <= k; j++){ maxc = max(dp[i][j], maxc); } } ll ans = 0; for(int i = 0; i <= k; i++){ for(int j = 0; j <= k; j++){ if(dp[i][j] == maxc){ ans = (ans+cnt[i][j])%MOD; } } } cout << maxc << endl; cout << ans << endl; return 0; }