Table
InterviewTime limit2sMemory limit1024 MB
Find an order of the k columns that sorts the n rows lexicographically in ascending order, or report -1 if no such order exists.
Statement
The Smith agents' database has rows, each with columns. In this problem, every cell in the table is an integer. The database was well structured and performed its tasks very well, until the malicious hacker Trinity broke into it and ruined its orderly structure. What she did was sacrilegious: she re-sorted the table her own way!
She fixed a permutation of the numbers from 1 to and sorted as follows: first, rows are sorted in ascending order of column . Among rows with equal values in column , they are sorted in ascending order of column . This continues in the same way for the remaining columns.
To restore the order, the agents need to know . Help the Smith agents!
Input
The first line contains and (), the number of rows and columns in the table. Each of the next lines contains integers , the elements of the table ().
Output
Print distinct numbers from 1 to , the permutation you are looking for. If several permutations fit, print any of them. If no such permutation exists, print -1.