import sys input = sys.stdin.readline N,P,K=map(int,input().split()) DP=[0]*(K+1) DP[0]=P for i in range(N): t,b=map(int,input().split()) for j in range(K-1,-1,-1): if t==1: DP[j+1]=max(DP[j+1],DP[j]+b) else: DP[j+1]=max(DP[j+1],DP[j]*2) if DP[-1]>10**18: print(-1) else: print(DP[-1])