n, p, k = map(int, input().split()) INF = float("INF") dp = [[-INF] * (k + 1) for _ in range(n + 1)] dp[0][0] = p for i in range(n): t, b = map(int, input().split()) for j in range(k + 1): dp[i + 1][j] = dp[i][j] for j in range(k): if t == 1: v = dp[i][j] + b else: v = dp[i][j] * 2 dp[i + 1][j + 1] = max(dp[i + 1][j + 1], v) if dp[i + 1][j + 1] >= 10**18: exit(print(-1)) print(dp[n][k])