N,V,C = map(int, input().split()) VW = [list(map(int, input().split())) for _ in range(N)] if not (1<=N<=1000 and 1<=V<=5000 and 1<=C<=5000): exit() for v,w in VW: if 1<=v<=5000 and 1<=w<=5000: continue exit() DP = [0]*(V+1) for v,w in VW: w+=C for i in reversed(range(V)): if DP[i]>0 and i+v<=V and DP[i+v]0 and i+v<=V and DP[i+v]