#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 sumA(1 << N, 0); vector sumB(1 << N, 0); for (int i = 0; i < (1 << N); i++){ for (int j = 0; j < N; j++){ if ((i >> j & 1) == 1){ sumA[i] += A[j]; sumB[i] += B[j]; } } } vector C(1 << N, 0); vector D(1 << N, 0); for (int i = 0; i < (1 << N); i++){ if (sumA[i] <= M){ C[i] = sumB[i]; } if (sumA[i] <= Q){ D[i] = sumB[i]; } } for (int i = 0; i < N; i++){ for (int j = 0; j < (1 << N); j++){ if ((j >> i & 1) == 1){ C[j] = max(C[j], C[j - (1 << i)]); D[j] = max(D[j], D[j - (1 << i)]); } } } long long ans = 0; for (int i = 0; i < (1 << N); i++){ ans = max(ans, C[i] + D[(1 << N) - 1 - i]); } cout << ans << endl; }