#include using namespace std; #define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define rep(i,n) REP(i,0,n) #define pb(a) push_back(a) #define F first #define S second typedef pair P; typedef pair P2; int main() { int n,b,ans=0; cin >> n >> b; P2 a[n]; rep(i,n) cin >> a[i].F.F >> a[i].F.S >> a[i].S; sort(a,a+n); rep(i,n) { if(i && a[i].F.F==a[i-1].F.F) continue; REP(j,i,n) { if(j v; REP(k,i,j+1) v.pb(P2(P(a[k].F.S,a[k].F.F),a[k].S)); sort(v.begin(),v.end()); int d[v.size()+1]; d[0]=0; rep(k,v.size()) d[k+1]=d[k]+v[k].S; rep(k,v.size()) { if(k && v[k].F.F==v[k-1].F.F) continue; REP(l,k,v.size()) { if(l