axis = [] for _ in range(int(input())) : x, y = map(int, input().split()) axis.append((x,y)) for tpl in sorted(axis, key = lambda x : (x[1], x[0])) : print(*tpl)