a=map(str.split,open('../fd/0')) for y,x in sorted([[~9L-`v`.count(e)for v in[a]+zip(*a)],e]for e in a.pop(0)):print x+`y`[6::3]