N, M = map(int, input().split()) for _ in range(M): A, B = map(int, input().split()) if A < B: print(A, B, flush=True) else: print(B, A, flush=True)