N,P,K=map(int,input().split()) inf=1<<60 dp=[-inf]*(K+1) dp[0]=P for i in range(N): T,B=map(int,input().split()) for k in range(K,0,-1): if T==1: x=min(dp[k-1]+B,inf) else: x=min(dp[k-1]*2,inf) dp[k]=max(dp[k],x) ans=dp[K] if ans>10**18: ans=-1 print(ans)