n, m, q = map(int, input().split()) # import sys # input = sys.stdin.readline # mp = map(int, sys.stdin.read().split()) # ab = list(zip(mp,mp)) ab = [] for i in range(n): a,b = map(int, input().split()) ab.append((a,b)) katidp = [[0 for i in range(1 << n)] for i in range(2)] resdp = [[0 for i in range(1 << n)] for i in range(2)] resdp[0][0] = m resdp[1][0] = q que = set(0) for j in range(n): nq = set() while que: state = que.pop() mkati = katidp[0][state] qkati = katidp[1][state] mres = resdp[0][state] qres = resdp[1][state] for k in range(n): if state & (1 << k): continue else: nstate = state | (1 << k) nq.add(nstate) kati = ab[k][1] val = ab[k][0] nkati = mkati + kati nres = mres - val if nres < 0: pass else: if katidp[0][nstate] < nkati: katidp[0][nstate] = nkati resdp[0][nstate] = nres elif katidp[0][nstate] == nkati: if resdp[0][nstate] < nres: resdp[0][nstate] = nres nkati = qkati + kati nres = qres - val if nres < 0: pass else: # nstate = state | (1 << k) if katidp[0][nstate] < nkati: katidp[0][nstate] = nkati resdp[0][nstate] = nres elif katidp[0][nstate] == nkati: if resdp[0][nstate] < nres: resdp[0][nstate] = nres que = nq mask = (1 << n) - 1 ans = 0 for i in range(1 << n): j = mask ^ i ans = max(ans, katidp[0][i] + katidp[1][j]) print(ans)