N,P,K = map(int,input().split()) TB = [list(map(int,input().split()))for _ in range(N)] dp=[[0]*(K+1)for i in range(N+1)] dp[0][0]=P for i in range(N): if TB[i][0]==1: for j in range(K): dp[i+1][j]=max(dp[i][j],dp[i+1][j]) if dp[i][j]>0: dp[i+1][j+1]=max(dp[i][j+1],dp[i][j]+TB[i][1]) else: for j in range(K): dp[i+1][j]=max(dp[i][j],dp[i+1][j]) if dp[i][j]>0: dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]*2) if dp[-1][-1]>=10**18: print(-1) else: print(dp[-1][-1])