#include //#include //using namespace atcoder; using namespace std; const int INF = 1e9; using ll = long long; using inv = vector; using stv = vector; using pint = pair; #define FOR(i,l,r) for(int i=(l); i<(r); i++) #define rep(i,r) for(int i=0; i<(r); i++) #define repl(i,r) for(long long i=0; i<(r); i++) #define FORl(i,l,r) for(long long i=(l); i<(r); i++) #define INFL ((1LL<<62)-(1LL<<31)) #define pb(x) push_back(x) #define CIN(x) cin >> x const ll MOD = 1e9+7; int N,X,Y; inv A(305),B(305),C(305); vector>> memo(305,vector>(305,vector(305,-1LL))); int main(){ cin >> N >> X >> Y; rep(i,N) cin >> A[i] >> B[i] >> C[i]; memo[0][X][Y] = 0LL; // rep(j,X+1) rep(k,Y+1){ // memo[0][j][k] = 0; // } FOR(i,1,N+1){ rep(j,X+1){ rep(k,Y+1){ if(memo[i-1][j][k] == -1) continue; if(j >= A[i-1] && k >= B[i-1]){ memo[i][j-A[i-1]][k-B[i-1]] = max(memo[i][j-A[i-1]][k-B[i-1]],memo[i-1][j][k]+C[i-1]); } memo[i][j][k] = memo[i-1][j][k]; } } } ll ans = -1LL; rep(j,X+1) rep(k,Y+1) ans = max(ans,memo[N][j][k]); cout << ans << endl; }