""" ナップザック 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())) mod = 998244353 dpmax = [float("-inf")] * (K+1) dpcnt = [0] * (K+1) dpmax[0] = 0 dpcnt[0] = 1 for csum in range(K): for c,d in zip(C,D): if csum+c <= K: nexd = dpmax[csum] + d if nexd > dpmax[csum+c]: dpmax[csum+c] = nexd dpcnt[csum+c] = 0 if nexd == dpmax[csum+c]: dpcnt[csum+c] += dpcnt[csum] dpcnt[csum+c] %= mod for i in range(K,-1,-1): if dpmax[i] >= 0: print (dpmax[i]) print (dpcnt[i] % mod) break