n, p, k = map(int, input().split()) m = 10 ** 18 + 1 dp = [[0 for _ in range(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] = max(dp[i + 1][j], dp[i][j]) if j != k: if t == 1: dp[i + 1][j + 1] = min(max(dp[i + 1][j + 1], dp[i][j] + b), m) else: dp[i + 1][j + 1] = min(max(dp[i + 1][j + 1], dp[i][j] * 2), m) print([max(dp[n]), -1][max(dp[n]) == m])