Permutation Recovery
시간 제한3초메모리 제한2048 MB
각 열이 뒤섞인 2k x n 행렬이 주어질 때, 각 행과 그 역순열을 모으면 열별 중복집합이 되는 1..n의 순열 k개를 복원한다.
문제
Initially, we had permutations of the integers from to . We created a matrix by writing each permutation as well as its inverse in its own row. However, we forgot the permutations, and someone shuffled every column. Given this matrix, can you determine any set of permutations which we could have started with?
입력
The first line contains two integers and (, ).
The -th of the following lines contains integers , the -th row of the matrix ().
It is guaranteed that the matrix could have been obtained as described above.
출력
Output lines. Each of them should contain a permutation of the integers from to . After writing these permutations as well as their inverses in the rows of a matrix, it must be possible to obtain the input matrix by reordering the values in every column.
If there are multiple solutions, output any of them.