#include #define rep(x, to) for (int x = 0; x < (to); x++) #define REP(x, a, to) for (int x = (a); x < (to); x++) #define EPS (1e-14) #define _PA(x,N) rep(i,N){cout< PII; typedef pair PLL; typedef complex Complex; typedef vector< vector > Mat; int ans; int N; pair< int, pair > xyz[1005], prev_xyz; int dp[1005]; void solve() { for (int i = 0; i < N; i++) { dp[i] = 1; } sort(xyz, xyz+N); for (int i = 0; i < N; i++) { for (int j = 0; j < i; j++) { if (xyz[j].fst < xyz[i].fst && xyz[j].snd.fst < xyz[i].snd.fst && xyz[j].snd.snd < xyz[i].snd.snd) { dp[i] = max(dp[i], dp[j] + 1); } } ans = max(ans, dp[i]); } cout << ans << endl; } int main() { cin >> N; rep(i, N) { int x[3]; cin >> x[0] >> x[1] >> x[2]; sort(x, x+3); xyz[i].fst = x[0]; xyz[i].snd.fst = x[1]; xyz[i].snd.snd = x[2]; } solve(); return 0; }