Under construction

Still being built. Things may change

Table

Interview

Time limit2sMemory limit1024 MB

Summary
Find an order of the k columns that sorts the n rows lexicographically in ascending order, or report -1 if no such order exists.
Level

Medium5 of 10

Topics
Greedy, Array
Solved
No attempts yet

Statement

The Smith agents' database has nn rows, each with kk 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 pp of the numbers from 1 to kk and sorted as follows: first, rows are sorted in ascending order of column p1p_1. Among rows with equal values in column p1p_1, they are sorted in ascending order of column p2p_2. This continues in the same way for the remaining columns.

To restore the order, the agents need to know pp. Help the Smith agents!

Input

The first line contains nn and kk (1≤n,k≤1031 \le n, k \le 10^3), the number of rows and columns in the table. Each of the next nn lines contains kk integers aija_{ij}, the elements of the table (1≤aij≤2×1031 \le a_{ij} \le 2 \times 10^3).

Output

Print kk distinct numbers from 1 to kk, the permutation you are looking for. If several permutations fit, print any of them. If no such permutation exists, print -1.

Examples2

  1. Example 1

    Input
    3 3
    2 3 1
    3 2 1
    1 2 2
    
    Expected output
    3 1 2
    
  2. Example 2

    Input
    2 2
    2 1
    1 1
    
    Expected output
    -1