#C7658. Max Nested Structures

    ID: 51553 Type: Default 1000ms 256MiB

Max Nested Structures

Max Nested Structures

In this problem, you are given a collection of three-dimensional structures. Each structure is represented by three positive integers corresponding to its dimensions. A structure A can be nested inside another structure B if and only if every dimension of A is strictly less than the corresponding dimension of B. Your task is to compute the maximum number of structures that can be nested one inside the other.

More formally, if a structure A with dimensions (a_1, a_2, a_3) and structure B with dimensions (b_1, b_2, b_3) satisfy [ a_1 < b_1, \quad a_2 < b_2, \quad a_3 < b_3, ] then A can be nested in B. Find the longest chain of such nestings.

inputFormat

The input is given via standard input. The first line contains an integer (n) representing the number of structures. Each of the following (n) lines contains three space-separated integers representing the dimensions of a structure.

outputFormat

Output a single integer via standard output, which is the maximum number of structures that can be nested inside each other.## sample

4
5 4 3
6 5 4
5 1 2
4 3 2
3