#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = (ll)1e18 + 1;

int N, K;
ll P, B[1010];
int T[1010];
ll dp[1010];
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> N >> P >> K;
    dp[0] = P;
    for(int i = 0;i < N;i++){
        int t, b; cin >> t >> b;
        for(int j = K - 1;j >= 0;j--){
            if(t == 1){
                dp[j + 1] = min(inf, max(dp[j + 1], dp[j] + b));
            }else{
                if(inf / 2 >= dp[j]){
                    dp[j + 1] = max(dp[j + 1], dp[j] * 2);
                }else{
                    dp[j + 1] = inf;
                }
            }
        }
    }
    cout << (dp[K] == inf ? -1 : dp[K]) << endl;
    return 0;
}