import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### n, W = na() v,w = zip(*[na() for _ in range(n)]) m = 10000 M = 2 * 10 ** 6 inf = 10**18 mod = 998244353 dp = [-inf] * (M + 1) dp[m] = 0 dpcnt = [0] * (M + 1) dpcnt[m] = 1 for i in range(n): ndp = [-inf] * (M + 1) ndpcnt = [0] * (M + 1) dp, ndp = ndp, dp dpcnt, ndpcnt = ndpcnt, dpcnt for j in range(M+1): if 0 <= j + w[i] <= M: if dp[j+w[i]] < ndp[j] + v[i]: dp[j+w[i]] = ndp[j] + v[i] dpcnt[j+w[i]] = ndpcnt[j] elif dp[j+w[i]] == ndp[j] + v[i]: dpcnt[j+w[i]] += ndpcnt[j] dpcnt[j+w[i]] %= mod if dp[j] < ndp[j]: dp[j] = ndp[j] dpcnt[j] = ndpcnt[j] elif dp[j] == ndp[j]: dpcnt[j] += ndpcnt[j] dpcnt[j] %= mod #print(dp) #print(dpcnt) ans = max(dp[:m + W + 1]) ans_cnt = 0 for i in range(m + W + 1): if dp[i] == ans: ans_cnt += dpcnt[i] ans_cnt %= mod print(ans, ans_cnt)