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