N,P,K=map(int,input().split()) L1=[] L2=[] for i in range(N): t,b=map(int,input().split()) if t==1: L1.append(b) else: L2.append(2) L1.sort(reverse=True) L2.sort(reverse=True) u=[1] for i in range(len(L2)): u.append(L2[i]) result=0 for j in range(1,K+1): if j>=len(u): break u[j]=u[j-1]*u[j] if u[j]>10**18: print(-1) exit() result=0 for i in range(len(L1)+1): if i>0: P+=L1[i-1] rest=K-i if rest<0: break if rest