N, P, K = map(int, input().split()) ans = [P] * (K + 1) inf = 10 ** 20 for _ in range(N) : t, b = map(int, input().split()) for i in range(K, 0, -1) : if t == 1 : ans[i] = max(ans[i], ans[i - 1] + b) else : ans[i] = max(ans[i], ans[i - 1] * 2) ans[i] = min(inf, ans[i]) print(-1 if ans[K] > 10 ** 18 else ans[K])