n = int(input()) def hikaku(s,t): if s[0]*t[1] >= s[1]*t[0]: return True else: return False li = [tuple(map(int,input().split())) for _ in range(n)] li.sort(key==hikaku,reverse=True) for x in li: print(*x)