#include <algorithm>
#include <cstdio>

using namespace std;

int n, k;

struct joke {
  int a[15], n;
};

joke a[100010];

bool operator < (const joke & a, const joke & b) {
  for (int i = 0; i < k; i++)
    if (a.a[i] > b.a[i]) return true; else
    if (a.a[i] < b.a[i]) return false;
  return false;
}

int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    a[i].n = i + 1;
    for (int j = 0; j < k; j++)
      scanf("%d", &a[i].a[j]);
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    printf("%d ", a[i].n);
  return 0;
}
