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]


                if mres < val:
                    nres = mres
                    nkati = mkati
                else:
                    nkati = mkati + kati
                    nres = mres - val

                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
                
                if qres < val:
                    nres = qres
                    nkati = qkati
                else:
                    nkati = qkati + kati
                    nres = qres - val

                if katidp[1][nstate] < nkati:
                    katidp[1][nstate] = nkati
                    resdp[1][nstate] = nres
                elif katidp[1][nstate] == nkati:
                    if resdp[1][nstate] < nres:
                        resdp[1][nstate] = nres
    que = nq

    # print(katidp)

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)