#include using namespace std; using ll = long long; #define REP(i, n) for (int i = 0; i < (n); i++) template using V = vector; template ostream &operator<<(ostream &os, const V &v) { os << "[ "; for (auto &vi: v) os << vi << ", "; return os << "]"; } template ostream &operator<<(ostream &os, const pair &p) { return os << "{ " << p.first << ", " << p.second << "}"; } #ifdef LOCAL #define show(x) cerr << __LINE__ << " : " << #x << " = " << x << endl; #else #define show(x) true #endif int main() { int N, X, Y; cin >> N >> X >> Y; vector dp(X + 1, vector(Y + 1, 0LL)); REP(i, N) { int a, b, c; cin >> a >> b >> c; auto np = dp; for (int x = 0; x <= X - a; x++) { for (int y = 0; y <= Y - b; y++) { np[x + a][y + b] = max(np[x + a][y + b], dp[x][y] + c); } } swap(dp, np); } long long ans = dp[X][Y]; cout << ans << '\n'; return 0; }