There is a game in which three dice with eyes from 1 to 6 are thrown to receive the prize money according to the following rules.
Rule (1) If you get three identical eyes, you will receive a prize of 10,000 KRW + (same eyes)1,000. Rule (2) If only two identical eyes come out, you will receive a prize of 1,000 KRW + (same eyes)100 KRW. Rule (3) If both eyes come out differently, you will receive a prize of 100 KRW.
For example, if you are given three eyes 3, 3, and 6, the prize money will be calculated as 1,000+3100, and you will receive 1,300 KRW. If the three eyes are given as 2, 2, and 2, it will be calculated as 10,000+21,000 and you will receive 12,000 KRW. If the three eyes are given as 6, 2, and 5, the largest value of them is 6, so it will be calculated as 6*100, and you will receive 600 KRW as a prize money.
The first line is given the number of participants N (2<=N<=1,000) and from the next line on N lines, each of the three eyes that people threw dice with the blank spaces between them.
In the first line, the prize money of the person who receives the most prize money is printed.
3
3 3 6
2 2 2
6 2 5
12000
n = int(input())
res = 0
for i in range (n):
li = input().split()
li.sort()
a,b,c = map(int, li)
if a == b and b == c:
m = 10000 + (a) * 1000
elif a == b or a == c:
m = 1000 + (a) * 100
elif b == c:
m = 1000 + (b) * 100
else:
m = c * 100
if m > res:
res = m
print (res)