#include using namespace std; int main() { int N, M, Q; cin >> N >> M >> Q; vector A(N), B(N); for(int i = 0; i < N; i++) { cin >> A[i] >> B[i]; } vector dpM(1 << N, 0), dpQ(1 << N, 0); for(int i = 0; i < 1 << N; i++) { long long asum = 0, bsum = 0; for(int j = 0; j < N; j++) { if(!((i >> j) & 1)) continue; asum += A[j]; bsum += B[j]; } if(asum <= M) dpM[i] = bsum; if(asum <= Q) dpQ[i] = bsum; } for(int i = 0; i < 1 << N; i++) { for(int j = 0; j < N; j++) { dpM[i | (1 << j)] = max(dpM[i | (1 << j)], dpM[i]); dpQ[i | (1 << j)] = max(dpQ[i | (1 << j)], dpQ[i]); } } long long ans = 0; for(int i = 0; i < 1 << N; i++) { int rembit = ((1 << N) - 1) ^ i; ans = max(ans, dpM[i] + dpQ[rembit]); } cout << ans << endl; return 0; }