#include <bits/stdc++.h>
//#include <atcoder/modint>
using namespace std;
//using namespace atcoder;
//using mint = modint998244353;
#define rep(i,n) for(long long i=0;i<n;i++)
#define rep1(i,n) for(long long i=1;i<=n;i++)
#define Rep(i,a,b) for(long long i=a;i<=b;i++)
#define all(a) (a).begin(), (a).end()
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vvec;
typedef vector<long long> vecll;
typedef vector<vector<long long>> vvecll;

//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

const ll mod=998244353;
//const ll mod=1e9+7;
const ll INF=5e18;
const int INT_INF=1e9;
const double pi=3.14159265358979;

//xのn乗をpで割ったあまりを求める
ll modpow(ll x,ll n,ll p=mod){
  if(n==0) return 1;
  if(n%2==1) return (x*modpow(x,n-1,p))%p;
  else{
    ll t=modpow(x,n/2,p);
    assert(t>0);
    return (t*t)%p;
  }
}

//xの逆元(p:素数)
ll inv(ll x,ll p=mod){
  return modpow(x,p-2,p);
}

template <typename T>
int index(vector<T> &a, T x){
	return lower_bound(all(a),x)-a.begin();
}

ll f(ll p,int t,ll b){
  if(t==1) p+=b;
  else p*=2;
  return p;
}

const ll M=1e18;

int main(){
	ll n,p,k;
  cin >> n >> p >> k;
  bool large=false;
  vecll dp(k+1,0);
  dp[0]=p;
  rep(i,n){
    int t;
    ll b;
    cin >> t >> b;
    vecll ndp=dp;
    rep1(j,k){
      ndp[j]=max(ndp[j],f(dp[j-1],t,b));
      if(ndp[j]>M){
        large=true;
        break;
      }
    }
    if(large) break;
    dp=move(ndp);
    //rep1(j,k) cout << dp[j] << " ";
    //cout << endl;
  }
  if(large) cout << -1 << endl;
  else{
    cout << dp[k] << endl;
  }
	return 0;
}