#include using namespace std; #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, x, y; cin >> n >> x >> y; constexpr ll INF = 1e18; vector dp(x + 1, vector(y + 1, -INF)); dp[0][0] = 0; rep(_, n) { ll a, b, c; cin >> a >> b >> c; vector ndp(x + 1, vector(y + 1, -INF)); rep(i, x + 1) rep(j, y + 1) { ndp[i][j] = max(ndp[i][j], dp[i][j]); if (i + a <= x && j + b <= y) ndp[i + a][j + b] = max(ndp[i + a][j + b], dp[i][j] + c); } swap(dp, ndp); } ll ans = -INF; rep(i, x + 1) rep(j, y + 1) ans = max(ans, dp[i][j]); cout << ans << '\n'; return 0; }