#include using namespace std; //* ATCODER #include using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template T max(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template T min(vector &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template T sum(vector &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ int n, k; cin >> n >> k; vector> dp(k+1, pair(-1, 0)); dp[0] = pair(0, 1); vector c(n), d(n); rep(i,0,n) cin >> c[i]; rep(i,0,n) cin >> d[i]; rep(j,0,k+1){ rep(i,0,n){ if (j+c[i] <= k){ if (dp[j+c[i]].first < dp[j].first + d[i]){ dp[j+c[i]].first = dp[j].first + d[i]; dp[j+c[i]].second = dp[j].second; }else if (dp[j+c[i]].first == dp[j].first + d[i]){ dp[j+c[i]].second += dp[j].second; } } } } int mt = 0; mint ans = 0; rep(i,0,k+1){ if (mt < dp[i].first){ mt = dp[i].first; ans = dp[i].second; }else if(mt == dp[i].first){ ans += dp[i].second; } } cout << mt << '\n'; cout << ans.val() << '\n'; }