############################################################# import sys sys.setrecursionlimit(10**7) from heapq import heappop,heappush from collections import deque,defaultdict,Counter from bisect import bisect_left, bisect_right from itertools import product,combinations,permutations ipt = sys.stdin.readline def iin(): return int(ipt()) def lmin(): return list(map(int,ipt().split())) MOD = 998244353 ############################################################# N,P,K = lmin() L = [lmin() for _ in range(N)] dp = [-1]*(K+1) dp[0] = P for t,b in L: ndp = dp[:] for j in range(K): if dp[j] == -1: break if t == 1: ndp[j+1] = max(ndp[j+1],dp[j]+b) else: ndp[j+1] = max(ndp[j+1],dp[j]*2) dp = ndp if max(dp) > 10**18: print(-1) exit() print(max(dp))