#include #include #include #include #include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; int main(){ int N, K; cin >> N >> K; vector C(N), D(N); rep(I,N) cin >> C[I]; rep(i,N) cin >> D[i]; vector dp0(K+1); vector dp1(K+1, 1); for(int k=1; k<=K; k++){ int f=0; rep(i,N) if(C[i] <= k) f = max(f, D[i] + dp0[k-C[i]]); dp0[k] = f; if(f != 0) dp1[k] = 0; rep(i,N) if(C[i] <= k && f == D[i] + dp0[k-C[i]]) dp1[k] += dp1[k-C[i]]; } cout << dp0[K] << '\n' << dp1[K].val() << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;