You have an infinite supply of rectangular bricks, each with dimensions x_i \times y_i \times z_i. Each brick can be oriented in any way, so any two dimensions can form the base while the third becomes the height.
Your task is to write a program that determines the maximum possible height of a tower that can be built from these bricks. A brick can be placed on top of another only if the base dimensions of the upper brick are strictly smaller than the base dimensions of the brick below.
The first line contains the number of types of bricks (1 \leq n \leq 30). Next follow integers describing the triples x_i, y_i, z_i—the dimensions of each brick type (1 \leq x_i, y_i, z_i \leq 65000).
Print a single integer—the maximum height of the tower.
Example 1
Example 2