#include using namespace std; using ll=long long; using pii=pair; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) const int N=305; int n,x,y; ll dp[N][N]; signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); cin >> n >> x >> y; for(int _=0; _> a >> b >> c; for(int i=x-a; i>=0; --i) for(int j=y-b; j>=0; --j) dp[i+a][j+b]=max(dp[i+a][j+b],dp[i][j]+c); } cout << dp[x][y] << "\n"; }