#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n, m, q; cin >> n >> m >> q; vector> a(n), b(1 << n); vector dp(1 << n); int U = (1 << n) - 1; for(auto &&[x, y] : a) cin >> x >> y; for(int S = 0; S < (1 << n); S++){ for(int i = 0; i < n; i++){ if(S >> i & 1){ b[S].first += a[i].first; b[S].second += a[i].second; } } if(b[S].first <= m) dp[S ^ U] = b[S].second; } ll ans = 0; for(int S = U; S >= 0; S--){ if(b[S].first <= q){ ans = max(ans, b[S].second + dp[S]); } for(int i = 0; i < n; i++){ if(S >> i & 1) dp[S ^ (1 << i)] = max(dp[S ^ (1 << i)], dp[S]); } } cout << ans << '\n'; }