from functools import cache MOD = 998244353 N, K = map(int, input().split()) C = list(map(int, input().split())) D = list(map(int, input().split())) def f(): dp = [0] * (K+1) for i in range(K): for j in range(N): c = C[j] d = D[j] if i+c > K: continue dp[i+c] = max(dp[i+c], dp[i] + d) m = 0 kk = 0 for k in range(K+1): if m < dp[k]: m = dp[k] kk = k return m, kk @cache def g(h, k): if k == 0: if h > 0: return 0 return 1 res = 0 for i in range(N): c = C[i] d = D[i] if h - d < 0 or k - c < 0: continue res += g(h-d, k-c) res %= MOD return res h, k = f() cnt = g(h, k) print(h) print(cnt)