N = int(input())
A, B = [], []
for i in range(N):
A.append(input()) #Фамилии
B.append(float(input())) #Средний
if B[i] >= 4.25:
print(A[i], B[i])
N = int(input())
A, B = [], []
for i in range(N):
A.append(input()) #Фамилии
for i in range(N):
B.append(float(input())) #Средний
for i in range(N):
if B[i] >= 4.25:
print(A[i], B[i])