#include using namespace std ; int main () { int N, X, Y; cin >> N >> X >> Y; using ll = long long; int A[330], B[330]; ll C[330]; for (int i = 0; i < N; i ++) cin >> A[i] >> B[i] >> C[i]; ll dp[330][330][330]; for (auto& a : dp) { for (auto& b : a) { for (auto& c : b) { c = 0; } } } for (int i = 1; i <= N; i ++) { for (int j = 0; j <= X; j ++) { for (int k = 0; k <= Y; k ++) { dp[i][j][k] = dp[i - 1][j][k]; if (j) { dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k]); } if (k) { dp[i][j][k] = max(dp[i][j][k], dp[i][j][k - 1]); } if (j >= A[i - 1] && k >= B[i - 1]) { dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j - A[i - 1]][k - B[i - 1]]); } } } } cout << dp[N][X][Y] << endl; }