#include #include #include using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,X,Y; cin>>N>>X>>Y; vector dp(X+1,vector(Y+1,-1LL<<60)); dp[0][0]=0; rep(i,N){ int a,b; ll c; cin>>a>>b>>c; vector dp2(X+1,vector(Y+1,-1LL<<60)); rep(j,X-a+1)rep(k,Y-b+1){ chmax(dp2[j+a][k+b],dp[j][k]+c); } rep(j,X+1)rep(k,Y+1)chmax(dp[j][k],dp2[j][k]); } ll ans=-1LL<<60; rep(i,X+1)rep(j,Y+1)chmax(ans,dp[i][j]); cout<