from collections import deque mod=998244353 from sys import stdin, setrecursionlimit input = stdin.readline readline = stdin.readline import math N,M,K=map(int, stdin.readline().split()) dp=[-1]*(K+1) dp[0]=M;f=0 for _ in range(N): t,b=map(int, stdin.readline().split()) ndp=[-1]*(K+1) # if f==1: # continue for i in range(K+1): ndp[i]=max(ndp[i],dp[i]) if i!=0: if t==1: ndp[i]=max(ndp[i],dp[i-1]+b) else: ndp[i]=max(ndp[i],dp[i-1]*2) dp=ndp # if dp[-1]>10**18: # f=1 if dp[-1]>10**18: print(-1) else: print(dp[-1])