datas = []
while True:
    try:
        line = input().strip()
        if not line:
            break
        datas.append(line)
    except EOFError:
        break

def sort_key(line):
    parts = line.split()
    num = float(parts[-1][:-3])
    other_parts = parts[1:3]
    return num, other_parts

datas.sort(key=sort_key)

for i in datas:
    print(i)