Team Contest

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

There are NN beavers in JOI University. All of them are working on competitive programming. Each beaver has three abilities: consideration skill, implementation skill, and luck. If the value of an ability is large, it means the level of the ability is high. For each ii (1iN1 ≤ i ≤ N), the consideration skill of the beaver ii is X_iX\_i, the implementation skill of the beaver ii is Y_iY\_i, and the luck of the beaver ii is Z_iZ\_i.

This year, the beavers of JOI University will attend a programming contest for teams. In this contest, the participants solve programming tasks, and each team consists of three beavers. Bitaro is a coach of JOI University. Since teamwork is very important, Bitaro decided to choose three beavers among the NN beavers and make a team so that the following condition is satisfied.

Condition Every member in the team has an advantage. This means every member has an ability whose value is strictly larger than the values of the same ability of the other two members.

Among possible teams satisfying the above condition, Bitaro wants to choose a team whose total ability is as large as possible. Here, the total ability of a team is defined as the sum of the maximum value of the consideration skill of the members of the team, the maximum value of the implementation skill of the members of the team, and the maximum value of the luck of the members of the team.

Write a program which, given information of the abilities of each beaver, determines whether it is possible to make a team satisfying the above condition, and, if it is possible to make a team, calculate the maximum possible value of the total ability of a team.

입력

Read the following data from the standard input. Given values are all integers.

\begin{align\*} & N \\\ & X\_1 \\, Y\_1 \\, Z\_1 \\\ & X\_2 \\, Y\_2 \\, Z\_2 \\\ & \vdots \\\ & X\_N \\, Y\_N \\, Z\_N \end{align\*}

출력

Write one line to the standard output. The output should contain the maximum possible value of the total ability of a team. If it is impossible to make a team satisfying the condition, output -1.

제한

  • 3N150,0003 ≤ N ≤ 150\\,000.
  • 1X_i100,000,0001 ≤ X\_i ≤ 100\\,000\\,000 (=108= 10^8) (1iN1 ≤ i ≤ N).
  • 1Y_i100,000,0001 ≤ Y\_i ≤ 100\\,000\\,000 (=108= 10^8) (1iN1 ≤ i ≤ N).
  • 1Z_i100,000,0001 ≤ Z\_i ≤ 100\\,000\\,000 (=108= 10^8) (1iN1 ≤ i ≤ N).