x=int(input())
f=[[0 for xx in range(5)] for xxx in range(x)]
for i in range(x):
f[i]=list(map(int,input().split()))
f[i].append(0)
f[i][4] = ( f[i][1]*5 + f[i][2]*3 + f[i][3]*2 )/10 # [0]座號 [1]資訊 [2]數學 [3]英文 [4]加權平均
for j in range(5):
f.sort( reverse = j , key = lambda n : n[j] ) #取加權平均比較(由大到小)(f本身改變 從最後比較的開始比較)
for l in f:
print( "{:g} {:g}" . format( l[0] , l[4] ) )