x=y=0 puts$<.sort_by{|_|[-_[R=/ \d+/].hex,$.]}.map{|_|x+=1 [y=$&==_[R]?y:x,_]*" "}