N,W = map(int, input().split()) DP = [(-10**9, 0)] * (2*10**4 + 1) DP[0] = (0, 1) # value, cnt P = 998244353 items = [list(map(int, input().split())) for _ in range(N)] items.sort(key=lambda x:x[1]) for v,w in items: if w >= 0: for w_ in range(W, -10**4-1, -1): if w_ + w <= W: v_,c_ = DP[w_] if v_+v == DP[w_+w][0]: DP[w_+w] = (v_+v, (DP[w_+w][1]+DP[w_][1]) % P) elif v_+v > DP[w_+w][0]: DP[w_+w] = (v_+v, DP[w_][1]) else: pass else: for w_ in range(-10**4, 1): #重さが負のものは最初に if DP[w_][0] == -10**9: continue v_,c_ = DP[w_] if v_+v == DP[w+w_][0]: DP[w_+w] = (v_+v, (DP[w_+w][1]+DP[w_][1]) % P) elif v_+v > DP[w+w_][0]: DP[w_+w] = (v_+v, DP[w_][1]) else: pass v_max = -10**9 c_ans = 0 for v,c in DP: if v > v_max: v_max = v c_ans = c elif v == v_max: c_ans += c print(v_max, c_ans % P)