n = int(input())
ma1 = 0
ma2 = 0
ma3 = 0
k = 0
mas = ['', '', '']
for i in range(n):
a, b, school, balls = input().split()
balls = int(balls)
if school == 50:
if balls >= ma1:
ma3 = ma2
ma2 = ma1
ma1 = balls
mas[2] = mas[1]
mas[1] = mas[0]
mas[0] = str(a)+str(b)
elif balls >= ma2:
ma3 = ma2
ma2 = balls
mas[2] = mas[1]
mas[1] = str(a)+str(b)
elif balls >= ma3:
ma3 == balls
mas[2] = str(a)+str(b)
if balls == ma1:
k += 1
if balls > ma1:
k = 0
if ma1 == ma2 and ma2 == ma3:
print(k)
if ma1 != ma2 and ma2 == ma3:
print(mas[0])
if ma2 != ma3 and ma1 == ma2:
print(mas[0])
print(mas[1])
print(mas)