#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b>n; ll a[n],b[n],c[n]; rep(i,n){ cin>>a[i]>>b[i]>>c[i]; dpa[1<>i)&1){ rep(j,n)if(((bit>>j)&1)==0){ // i: last, j: nxt // a ll ln=max(b[i],c[i]),sh=min(b[i],c[i]); if(max(b[j],c[j])<=ln and min(b[j],c[j])<=sh) chmax(dpa[bit|(1<