#include #define REP(i,n,N) for(int i=(n);i<(int) N;i++) #define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--) #define p(s) cout<<(s)<>> a; int LIS1(int n){ vector> dp; dp.push_back({a[0].S.F,a[0].S.S}); REP(i,1,n){ REP(j,0,dp.size()){ if(dp[j].F>a[i].S.F && dp[j].S>a[i].S.S) { dp[j]={a[i].S.F,a[i].S.S}; break; } } if(dp.back().F>N; REP(i,0,N){ int tmp[3]; cin>>tmp[0]>>tmp[1]>>tmp[2]; sort(tmp,tmp+3); a.push_back({tmp[0],{tmp[1],tmp[2]}}); } sort(a.begin(),a.end()); //b.push_back({a[0][1],a[0][2]}); REP(i,1,a.size()){ if(a[i-1].F==a[i].F) { a.erase(a.begin()+i); i--; } } int ans=LIS1(a.size()); p(ans); return 0; }