#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,n) for(int i=0; i=b; --i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; typedef vector VI; typedef vector VL; typedef vector VVI; typedef pair P; typedef pair PL; int main() { int n; cin >> n; vector > a(n); REP(i,n){ VI x(3); REP(i,3) cin >> x[i]; sort(ALL(x)); a[i].first = x[0]; a[i].second.first = x[1]; a[i].second.second = x[2]; } sort(ALL(a)); VI dp(n,1); FOR(i,1,n-1){ REP(j,i){ if (a[i].first > a[j].first && a[i].second.first > a[j].second.first && a[i].second.second > a[j].second.second){ dp[i] = max(dp[i], dp[j] + 1); } } } int ans = 0; REP(i,n) ans = max(ans, dp[i]); cout << ans << endl; return 0; }