from functools import cache import sys sys.setrecursionlimit(10 ** 6) 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) pp = [0] * (K+1) pp[0] = 1 for i in range(K): for j in range(N): c = C[j] d = D[j] if i+c > K: continue if dp[i+c] == dp[i] + d: pp[i+c] += pp[i] pp[i+c] %= MOD elif dp[i+c] < dp[i] + d: dp[i+c] = dp[i] + d pp[i+c] = pp[i] m = 0 cnt = 1 for k in range(K+1): if m < dp[k]: m = dp[k] cnt = pp[k] return m, cnt h, cnt = f() print(h) print(cnt)