""" ナップザック dp[] """ import sys from sys import stdin N,K = map(int,stdin.readline().split()) C = list(map(int,stdin.readline().split())) D = list(map(int,stdin.readline().split())) assert 1 <= N <= 1000 assert 1 <= K <= 1000 for i in range(N): assert 1 <= C[i] <= 1000 assert 1 <= D[i] <= 1000 mod = 998244353 dpmax = [float("-inf")] * (K+1) dpcnt = [0] * (K+1) dpmax[0] = 0 dpcnt[0] = 1 for csum in range(K+1): for c,d in zip(C,D): if csum+c <= K: nexc = csum+c nexd = dpmax[csum] + d if nexd > dpmax[nexc]: dpmax[nexc] = nexd dpcnt[nexc] = 0 if nexd == dpmax[nexc]: dpcnt[nexc] += dpcnt[csum] dpcnt[nexc] %= mod ans = [0,0] for i in range(K,-1,-1): if dpmax[i] > ans[0]: ans = [dpmax[i],0] if dpmax[i] == ans[0]: ans[1] += dpcnt[i] print (ans[0]) print (ans[1] % mod)