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 java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;
import java.io.BufferedReader;
import java.util.List;
import java.util.Collections;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.Arrays;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AlexFetisov
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD_toposort solver = new TaskD_toposort();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD_toposort {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            final int[][] a = new int[n][m];
            Integer[][] p = new Integer[n][m];

            int addV = m;
            List<TaskD_toposort.Edge> edges = new ArrayList<TaskD_toposort.Edge>();

            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    a[i][j] = in.nextInt();
                    p[i][j] = j;
                }
                final int finalI = i;
                Arrays.sort(p[i], new Comparator<Integer>() {

                    public int compare(Integer o1, Integer o2) {
                        return a[finalI][o1] - a[finalI][o2];
                    }
                });

                int blockStart = 0, blockEnd = 0;
                int prevV = addV++;

                for (int j = 1; j < m; ++j) {
                    int realI = p[finalI][j];
                    if (a[i][realI] == a[i][p[i][j - 1]]) {
                        blockEnd = j;
                    } else {
                        if (a[i][p[i][blockStart]] != -1) {
                            int nextV = addV++;
                            for (int k = blockStart; k <= blockEnd; ++k) {
                                int V = p[i][k];
                                edges.add(new TaskD_toposort.Edge(prevV, V));
                                edges.add(new TaskD_toposort.Edge(V, nextV));
                            }
                            prevV = nextV;
                        }
                        blockStart = j;
                        blockEnd = j;
                    }
                }
                for (int k = blockStart; k <= blockEnd; ++k) {
                    int V = p[i][k];
                    edges.add(new TaskD_toposort.Edge(prevV, V));
                }
            }

            Graph g = new Graph();
            g.initGraph(addV, edges.size());
            for (TaskD_toposort.Edge e : edges) {
                g.addDirectEdge(e.from, e.to);
            }
            final int[] color = StrongComponents.run(g);
            List<Integer> result = new ArrayList<Integer>(n);
            for (int i = 0; i < m; ++i) {
                result.add(i);
            }
            Collections.sort(result, new Comparator<Integer>() {

                public int compare(Integer o1, Integer o2) {
                    return color[o2] - color[o1];
                }
            });
            int[][] b = new int[n][m];
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    b[i][j] = a[i][result.get(j)];
                }
            }
            for (int i = 0; i < n; ++i) {
                if (b[i][0] == -1) {
                    b[i][0] = 0;
                }
                for (int j = 1; j < m; ++j) {
                    if (b[i][j] == -1) {
                        b[i][j] = b[i][j - 1];
                    }
                    if (b[i][j] < b[i][j - 1]) {
                        out.println(-1);
                        return;
                    }
                }
            }

            for (int i : result) {
                out.print((i + 1) + " ");
            }
            out.println();
        }

        class Edge {
            int from;
            int to;

            public Edge(int to, int from) {
                this.to = to;
                this.from = from;
            }

        }

    }

    static class StrongComponents {
        static int[] colors;
        static List<Integer> order;
        static Graph g;
        static Graph gr;

        public static int[] run(int n, Graph ig, Graph igr) {
            g = ig;
            gr = igr;
            colors = new int[n];
            order = new ArrayList<Integer>(n);
            for (int i = 0; i < n; ++i) {
                if (colors[i] == 0) {
                    dfs1(i);
                }
            }
            Arrays.fill(colors, -1);
            int nextColor = 0;
            for (int i = 0; i < n; ++i) {
                int v = order.get(n - 1 - i);
                if (colors[v] == -1) {
                    dfs2(v, nextColor++);
                }
            }
            return colors;
        }

        private static void dfs1(int v) {
            colors[v] = 1;
            for (int i = g.first[v]; i != -1; i = g.next[i]) {
                if (colors[g.to[i]] == 0) {
                    dfs1(g.to[i]);
                }
            }
            order.add(v);
        }

        private static void dfs2(int v, int color) {
            colors[v] = color;
            for (int i = gr.first[v]; i != -1; i = gr.next[i]) {
                if (colors[gr.to[i]] == -1) {
                    dfs2(gr.to[i], color);
                }
            }
        }

        public static int[] run(Graph g) {
            Graph ig = new Graph();
            ig.initGraph(g.nVertex, g.nEdges);
            for (int v = 0; v < g.nVertex; ++v) {
                for (int e = g.first[v]; e != -1; e = g.next[e]) {
                    int to = g.to[e];
                    ig.addDirectEdge(to, v);
                }
            }
            return run(g.nVertex, g, ig);
        }

    }

    static class Graph {
        public int[] from;
        public int[] to;
        public int[] first;
        public int[] next;
        public int nVertex;
        public int nEdges;
        public int curEdge;

        public Graph() {
        }

        public void initGraph(int n, int m) {
            curEdge = 0;
            nVertex = n;
            nEdges = m;
            from = new int[m * 2];
            to = new int[m * 2];
            first = new int[n];
            next = new int[m * 2];
            Arrays.fill(first, -1);
        }

        public void addDirectEdge(int a, int b) {
            next[curEdge] = first[a];
            first[a] = curEdge;
            to[curEdge] = b;
            from[curEdge] = a;
            ++curEdge;
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String nextString() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

    }
}