with([])for(;;s?push([s[-1]+8,s]):print(shift(sort())[1]))s=readline()