Problem: Lenny had an n × m matrix of positive integers. He loved the matrix so much, because each row of the matrix was sorted in non-decreasing order. For the same reason he calls such matrices of integers lovely.

One day when Lenny was at school his little brother was playing with Lenny's matrix in his room. He erased some of the entries of the matrix and changed the order of some of its columns. When Lenny got back home he was very upset. Now Lenny wants to recover his matrix.

Help him to find an order for the columns of the matrix so that it's possible to fill in the erased entries of the matrix to achieve a lovely matrix again. Note, that you can fill the erased entries of the matrix with any integers.

Input

The first line of the input contains two positive integers n and m (1 ≤ n·m ≤ 105). Each of the next n lines contains m space-separated integers representing the matrix. An integer -1 shows an erased entry of the matrix. All other integers (each of them is between 0 and 109 inclusive) represent filled entries.

Output

If there exists no possible reordering of the columns print -1. Otherwise the output should contain m integers p1, p2, ..., pm showing the sought permutation of columns. So, the first column of the lovely matrix will be p1-th column of the initial matrix, the second column of the lovely matrix will be p2-th column of the initial matrix and so on.

Examples

Input

3 3
1 -1 -1
1 2 1
2 -1 1


Output

3 1 2 


Input

2 3
1 2 2
2 5 4


Output

1 3 2 


Input

2 3
1 2 3
3 2 1


Output

-1

Solution (in JAVA):

Solution:
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;

public class D274 {
    public static Scanner sc=new Scanner(in);
    //public static Random sc=new Random();

    class Cols{
        int id;
        int[] vals;

        Cols(int _id,int[] v){
            id=_id;vals=v;
        }

        @Override
        public String toString() {
            return id+1+"";
        }
    }

    void run() throws Exception{
        BufferedReader buf = new BufferedReader(new InputStreamReader(in));

        String[] line=buf.readLine().split(" ");
        final int n=Integer.parseInt(line[0]),m=Integer.parseInt(line[1]);

        int[][] map=new int[n][m];
        for(int i=0;i<n;i++){
            String[] str=buf.readLine().split(" ");
            for(int j=0;j<m;j++){
                map[i][j]=Integer.parseInt(str[j]);
            }
        }

        //create node
        Cols[] cs=new Cols[(n+2)*(m+2)];
        for(int j=0;j<m;j++){
            int[] vs=new int[n];
            for(int i=0;i<n;i++)vs[i]=map[i][j];

            cs[j]=new Cols(j,vs);
        }
        for(int j=m;j<(n+2)*(m+2);j++)cs[j]=new Cols(j,null);

        //create link
        Collection<Cols>[] links=new Set[(n+2)*(m+2)];
        Collection<Cols>[] revlinks=new Set[(n+2)*(m+2)];
        for(int f=0;f<(n+2)*(m+2);f++){
            links[f]=new HashSet<>();
            revlinks[f]=new HashSet<>();
        }
        int dummyind=m;
        for (int i = 0; i < n; ++i) {
            Integer order[] = new Integer[m];
            final int[] col=new int[m];
            for (int j = 0; j < m; ++j) {
                order[j] = j;
                col[j] =map[i][j];
            }
            Arrays.sort(order, new Comparator<Integer>() {
                @Override
                public int compare(Integer u, Integer v) {
                    return col[u] - col[v];
                }
            });

            int p=0;while(p<m && col[order[p]]==-1)p++;
            if(p==m)continue;

            int f=p;
            Cols prev=new Cols(dummyind++,null);
            while(f<m){
                int val=col[order[f]];
                Cols dummy=new Cols(dummyind++,null);
                links[order[f]].add(dummy);revlinks[dummy.id].add(cs[order[f]]);
                links[prev.id].add(cs[order[f]]);revlinks[order[f]].add(prev);
                while(f+1<m && val==col[order[f+1]]){
                    f++;

                    links[order[f]].add(dummy);revlinks[dummy.id].add(cs[order[f]]);
                    links[prev.id].add(cs[order[f]]);revlinks[order[f]].add(prev);
                }

                prev=dummy;
                f++;
            }
        }

        List<Cols> res=new ArrayList<Cols>();
        Queue<Cols> tasks=new LinkedList<>();
        boolean[] passed=new boolean[(n+2)*(m+2)];
        for(int f=0;f<(n+2)*(m+2);f++)if(revlinks[f].size()==0){
            tasks.add(cs[f]);
            passed[f]=true;
        }

        while(!tasks.isEmpty()){
            Cols task=tasks.poll();
            if(task.id<m)res.add(task);

            linkl:for(Cols link:links[task.id]){
                if(!passed[link.id]){
                    for(Cols revlink:revlinks[link.id])if(!passed[revlink.id])continue linkl;

                    passed[link.id]=true;
                    tasks.add(link);
                }
            }
        }

        for(int i=0;i<m;i++)if(!passed[i]){
            ln(-1);return;
        }
        ln(str(res));
    }

    public static void main(String[] args) throws Exception {
        new D274().run();
    }


    //output lib
    static final String br=System.getProperty("line.separator");
    static final String[] asep=new String[]{""," ",br,br+br};
    static String str(boolean o){
        return o?"YES":"NO";
    }
    static <K,V> String str(Map<K, V> map){
        StringBuilder sb=new StringBuilder();
        boolean isFirst=true;
        for(Entry<K,V> set:map.entrySet()){
            if(!isFirst)sb.append(br);
            sb.append(str(set.getKey())).append(":").append(str(set.getValue()));
            isFirst=false;
        }
        return sb.toString();
    }
    static <E> String str(Collection<E> list){
        StringBuilder sb=new StringBuilder();
        boolean isFirst=true;
        for(E e:list){
            if(!isFirst)sb.append(" ");
            sb.append(str(e));
            isFirst=false;
        }
        return sb.toString();
    }
    static String str(Object o){
        int depth=_getArrayDepth(o);
        if(depth>0)return _strArray(o,depth);
        return o.toString();
    }
    static int _getArrayDepth(Object o){
        if(!o.getClass().isArray() || Array.getLength(o)==0) return 0;
        return  1+_getArrayDepth(Array.get(o,0));
    }
    //depth ex A[10]…1 A[10][10]…2 exception A[0]…0 A[10][0]…1 A[0][0]…0
    static String _strArray(Object o,int depth){
        if(depth==0) return str(o);
        StringBuilder sb=new StringBuilder();
        for(int i=0,len=Array.getLength(o);i<len;i++){
            if(i!=0)sb.append(asep[depth]);
            sb.append(_strArray(Array.get(o,i),depth-1));
        }
        return sb.toString();
    }
    static void pr(Object... os){
        boolean isFirst=true;
        for(Object o:os){
            if(!isFirst)out.print(" ");
            out.print(o);
            isFirst=false;
        }
    }
    static void ln(){
        out.println();
    }
    static void ln(Object... os){
        for(Object o:os){
            pr(o);ln();
        }
    }
}