#t262. 奖学金

奖学金

Scholarships

Problem Background

NOIP 2007, Popularization Group, Problem T1.

Problem Description

A primary school has recently received a sponsorship and plans to use part of it to award scholarships to the top 55 students with the best academic performance. At the end of the term, each student has scores in 33 subjects: Chinese, Mathematics, and English.

First sort by total score from highest to lowest. If two students have the same total score, sort by Chinese score from highest to lowest. If both the total score and the Chinese score are equal, the student with the smaller student ID ranks first. In this way each student's rank is uniquely determined.

Your task: first compute the total score from the 33 subjects, then sort according to the rules above, and finally output the student ID and total score of the top 55 students in rank order.

Note that among the top 55 students, each one's scholarship is different, so you must sort strictly by the rules above. For example, in a correct answer, if the first two output lines (each line has two numbers: student ID and total score) are:

7 279
5 279

their meaning is: the two students with the highest total scores have IDs 77 and 55 in that order. Both have a total score of 279279 (the sum of Chinese, Mathematics, and English), but the student with ID 77 has a higher Chinese score.

If your output for the top two is:

5 279
7 279

it will be treated as an output error and scored zero.

Input Format

There are n+1n + 1 lines in total.

The first line is a positive integer n≤300n \le 300, the number of students participating in the selection.

Lines 22 through n+1n + 1: each line has 33 space-separated numbers, each between 00 and 100100. The 33 numbers in line jj are respectively the Chinese, Mathematics, and English scores of the student whose ID is j−1j - 1. Each student is numbered 1∼n1 \sim n in input order (exactly the line number minus 11).

The given data is guaranteed to be correct; no validation is needed.

Output Format

Output 55 lines in total. Each line contains two space-separated positive integers: the student ID and total score of one of the top 55 students, in rank order.

Sample Input

6
90 67 80
87 66 91
78 89 91
88 99 77
67 89 64
78 89 98

Sample Output

6 265
4 264
3 258
2 244
1 237

Sample Input 2

8
80 89 89
88 98 78
90 67 80
87 66 91
78 89 91
88 99 77
67 89 64
78 89 98

Sample Output 2

8 265
2 264
6 264
1 258
5 258