#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16000000 )   using namespace std;   const int inf = 0x3f3f3f3f;   const long long inf2 = 0x3f3f3f3f3f3f3f3f;   const double eps = 1e-6;   const int mod = 1000000007;   namespace fastio {   char in[100000];   int itr = 0, llen = 0;   char get() {     if (itr == llen) llen = fread(in, 1, 100000, stdin), itr = 0;     if (llen == 0) return EOF;     return in[itr++];   }   char out[100000];   int itr2 = 0;   void put(char c) {     out[itr2++] = c;     if (itr2 == 100000) {       fwrite(out, 1, 100000, stdout);       itr2 = 0;     }   }   int clear() {     fwrite(out, 1, itr2, stdout);     itr2 = 0;     return 0;   }   int getint() {     int r = 0;     bool ng = 0;     char c;     c = get();     while (c !=  -  && (c <  0  || c >  9 )) c = get();     if (c ==  - ) ng = 1, c = get();     while (c >=  0  && c <=  9 ) r = r * 10 + c -  0 , c = get();     return ng ? inf : r;   }   string getstr() {     string ret =   ;     char ch = get();     while (ch ==     || ch ==   n ) ch = get();     while (ch !=     && ch !=   n ) ret.push_back(ch), ch = get();     return ret;   }   void putstr(string s) {     for (int i = 0; i < s.size(); i++) put(s[i]);   }   void putint(int x) {     if (x == 0) {       put( 0 );       return;     }     char c[20];     int pos = 0;     while (x) {       c[pos++] =  0  + x % 10;       x /= 10;     }     for (int i = pos - 1; i >= 0; i--) put(c[i]);   }   void getarr(int arrname[], int size) {     for (int i = 0; i < size; i++) arrname[i] = getint();   }   }  // namespace fastio   using namespace fastio;   int n, m;   bool used[111111 * 5];   vector<int> g[111111 * 5];   int deg[111111 * 5];   vector<pair<int, int> > edges;   vector<int> ans;   void dfs(int x, int par) {     used[x] = true;     ans.push_back(x);     for (auto p : g[x]) {       deg[p]--;       if (deg[p] == 0) dfs(p, x);     }   }   int main() {     n = getint();     m = getint();     vector<vector<int> > vec(n, vector<int>(m));     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) vec[i][j] = getint();     int pre = m;     for (int i = 0; i < n; i++) {       bool buff = (i == 0);       vector<pair<int, int> > V;       for (int j = 0; j < m; j++) V.push_back(make_pair(vec[i][j], j));       sort(V.begin(), V.end());       while (V.back().first == inf) V.pop_back();       if (!V.size()) continue;       int pos = 0;       set<int> Set;       Set.clear();       for (int ii = 0; ii < V.size(); ii++) {         Set.insert(V[ii].first);       }       bool first = true;       for (set<int>::iterator itr = Set.begin(); itr != Set.end(); itr++) {         int p = *itr;         set<int>::iterator itr2 = itr;         itr2++;         bool last = itr2 == Set.end();         for (int &t = pos; t < V.size() && V[t].first == p; t++) {           if (!first)             g[pre].push_back(V[t].second), deg[V[t].second]++,                 cerr << V[t].second << endl;           if (Set.size() != 1 && !last)             g[V[t].second].push_back(pre + 1), deg[pre + 1]++,                 cerr << pre << endl;         }         if (Set.size() != 1) pre++;         first = false;       }     }     cerr <<  Start top sort: n ;     for (int i = 0; i < pre; i++)       if (!used[i] && !deg[i]) dfs(i, -1);     vector<int> ans2;     ans2.clear();     for (int i = 0; i < ans.size(); i++)       if (ans[i] < m) ans2.push_back(ans[i]);     if (ans2.size() < m) {       puts( -1 );       return 0;     } else {       for (int i = 0; i < ans2.size(); i++) putint(ans2[i] + 1), put(   );       return clear();     }     return 0;   }