n,p,k=map(int,input().split()) dp=[-1]*(k+1) dp[0]=p for i in range(n): a,b=map(int,input().split()) if a==1: for j in range(1,k+1): if dp[-j-1]==-1: continue dp[-j]=max(dp[-j],dp[-j-1]+b) if dp[-j]>10**18: print(-1) exit() else: for j in range(1,k+1): if dp[-j-1]==-1: continue dp[-j]=max(dp[-j],dp[-j-1]*2) if dp[-j]>10**18: print(-1) exit() print(dp[-1])