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