func_code_string: #include <bits/stdc++.h>   using namespace std;   struct node {     int va, num;     bool operator<(const node &o) const { return va < o.va; }   } a[100005];   int n, m, nub, lastnode, nextnode, now;   int mark[400005], mm;   int ans[400005], co;   vector<int> save[400005];   void dfs(int h) {     mark[h] = 1;     for (int i = 0; i < save[h].size(); i++) {       if (mark[save[h][i]] == 1) {         mm = 1;         return;       }       if (mark[save[h][i]] == 0) {         dfs(save[h][i]);       }     }     ans[co] = h;     co++;     mark[h] = 2;   }   int main() {     scanf( %d %d , &n, &m);     nub = m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         scanf( %d , &a[j].va);         a[j].num = j;       }       sort(&a[0], &a[m]);       lastnode = -1;       for (int j = 0; j < m; j++) {         if (a[j].va == -1) continue;         nub++;         nextnode = nub;         now = a[j].va;         while (j < m && a[j].va == now) {           if (lastnode != -1) {             save[lastnode].push_back(a[j].num);           }           save[a[j].num].push_back(nextnode);           j++;         }         j--;         lastnode = nextnode;       }     }     for (int i = 0; i <= nub; i++) {       if (!mark[i]) {         dfs(i);       }     }     if (mm) {       printf( -1 n );     } else {       for (int i = co - 1; i >= 0; i--) {         if (ans[i] < m) {           printf( %d  , ans[i] + 1);         }       }       printf(  n );     }   }   