import sys input = sys.stdin.readline mod=998244353 N,W=map(int,input().split()) DP=[[-1<<60,-1<<60] for i in range(200010+1)] DP[10010]=[0,1] for i in range(N): v,w=map(int,input().split()) NDP=[[-1<<60,-1<<60] for i in range(200010+1)] for j in range(200010+1): NDP[j][0],NDP[j][1]=DP[j][0],DP[j][1] for j in range(200010+1): if DP[j][1]<0: continue k,c=DP[j] v2=k+v if j+w<200010+1: if NDP[j+w][0]>v2: pass elif NDP[j+w][0]==v2: NDP[j+w][1]+=c else: NDP[j+w]=[v2,c] DP=NDP #print(DP[10010:10015]) #print(max(DP)) MAX=max(DP[:W+10010+1])[0] ANS=0 for i in range(W+10010+1): if DP[i][0]==MAX: ANS+=DP[i][1] print(MAX,ANS%mod)