#include #define REP(i,n) for(int i=0,i##_len=int(n);i>N; vector A(N),B(N),C(N); REP(i,N) cin>>A[i]>>B[i]>>C[i]; vector>> graph(N); REP(i,N) REP(j,N) if(i!=j){ if(A[i]<=B[j]-C[j]) graph[i].push_back(make_pair(-B[i],j)); } vector dist(N,0); REP(i,N-1) REP(j,N){ REP(k,graph[j].size()){ int TO=graph[j][k].second,COST=graph[j][k].first; dist[TO]=min(dist[TO],dist[j]+COST); } } vector negative(N,false); REP(i,N) REP(j,N){ REP(k,graph[j].size()){ int TO=graph[j][k].second,COST=graph[j][k].first; if(dist[TO]>dist[j]+COST){ dist[TO]=dist[j]+COST; negative[TO]=true; } if(negative[j]) negative[TO]=true; } } REP(i,N){ if(negative[i]) cout<<"BAN"<