# 自力できず、公式解説より # 2次元dpで、満腹度、幸福度、食べ方何通りを含めてしまう # dp[満腹度i][幸福度の最大値, 食べ方何通り] N, K = map(int, input().split()) C = list(map(int, input().split())) D = list(map(int, input().split())) mod = 998244353 dp = [[0, 0] for i in range(K+1)] dp[0] = [0, 1] for i in range(K+1): if dp[i][1] == 0: continue for j in range(N): c, d = C[j], D[j] if i+c <= K: if dp[i][0]+d > dp[i+c][0]: dp[i+c][0] = dp[i][0]+d dp[i+c][1] = dp[i][1] elif dp[i][0]+d == dp[i+c][0]: dp[i+c][1] += dp[i][1] dp[i+c][1] %= mod #print(dp[i]) # 必要なのは満腹度K以下での、幸福度最大値と食べ方何通り happiness = 0 ways = 0 for i in range(K+1): if dp[i][0] > happiness: happiness = dp[i][0] ways = dp[i][1] elif dp[i][0] == happiness: ways += dp[i][1] ways %= mod print(happiness) print(ways)