N, P, K = map(int, input().split()) items = [] for _ in range(N): T, B = map(int, input().split()) items.append((T, B)) dp = [[0] * (K+1) for _ in range(N+1)] dp[0][0] = P for i in range(N): for j in range(K+1): dp[i+1][j] = dp[i][j] t, b = items[i] for j in range(K): if t == 1: dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + b) else: dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] * 2) res = dp[N][K] if res > 10**18: print(-1) else: print(res)