import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static final long MAX = 1000000000000000000L; static long[][] dp; static long p; static boolean[] isDouble; static int[] values; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); p = sc.nextLong(); int k = sc.nextInt(); isDouble = new boolean[n]; values = new int[n]; for (int i = 0; i < n; i++) { isDouble[i] = sc.nextInt() == 2; values[i] = sc.nextInt(); } dp = new long[n][k + 1]; for (long[] arr : dp) { Arrays.fill(arr, Long.MIN_VALUE); } long ans = dfw(n - 1, k); System.out.println(ans > MAX ? -1 : ans); } static long dfw(int idx, int v) { if (idx + 1 < v) { return Long.MIN_VALUE / 2; } if (v == 0) { return p; } if (dp[idx][v] == Long.MIN_VALUE) { dp[idx][v] = Math.max(dfw(idx - 1, v), func(isDouble[idx], values[idx], dfw(idx - 1, v - 1))); } return dp[idx][v]; } static long func(boolean isD, int v, long current) { if (isD) { return Math.min(MAX + 1, current * 2); } else { return Math.min(MAX + 1, current + v); } } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }