#include <cstdio>
#include <cstring>
using namespace std;
#define Nmax 100003
#define Mmax 13
int N, M;
int v[Mmax][Nmax];
int buk[Nmax];
int ls[2][Nmax];
inline void bucketsort(int b[], int h[], int e[], int n) {
memset(buk, 0, sizeof(buk));
for (int i = 1; i <= n; i++)
buk[h[b[i]]]++;
for (int i = 1; i <= 1000; i++)
buk[i] += buk[i-1];
for (int i = n; i >= 1; i--)
e[buk[h[b[i]]]--] = b[i];
}
int main() {
freopen("Bucketsort.in", "r", stdin);
freopen("Bucketsort.out", "w", stdout);
scanf("%d %d", &N, &M);
for (int j = 1; j <= M; j++)
for (int i = 1; i <= N; i++)
scanf("%d", &v[j][i]);
int lt = 0, nw = 1;
for (int i = 1; i <= N; i++)
ls[lt][i] = i;
for (int j = M; j >= 1; j--) {
bucketsort(ls[lt], v[j], ls[nw], N);
lt = nw;
nw ^= 1;
}
for (int i = 1; i <= N; i++)
printf("%d ", ls[lt][i]);
return 0;
}