#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,c=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