#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, x, y, a, b, c; cin >> n >> x >> y; ll dp[x + 1][y + 1] = {}; ll ans = 0; for(int i = 0; i < n; i++){ cin >> a >> b >> c; for(int j = x - a; j >= 0; j--){ for(int k = y - b; k >= 0; k--){ dp[j + a][k + b] = max(dp[j + a][k + b], dp[j][k] + c); } } } for(int i = 0; i <= x; i++){ for(int j = 0; j <= y; j++){ ans = max(ans, dp[i][j]); } } cout << ans << '\n'; }