N,P,K=map(int,input().split()) T=[] B=[] for _ in range(N): t,b=map(int,input().split()) T.append(t) B.append(b) ans=0 for i in range(N-K+1): tmp=P for k in range(K): if T[i+k]==1:tmp+=B[i+k] else:tmp*=2 ans=max(ans,tmp) print(ans if ans<=10**18 else -1)