#include <bits/stdc++.h>
int n, m;
int a[2000003];
struct asd {
  int a, id;
} b[2000003];
int du[2000003], ans[2000003], d[2000003];
bool cmp(asd a, asd b) { return a.a < b.a; };
inline int get(int x, int y) { return m * (x - 1) + y; };
std::vector<int> e[2000003];
std::vector<int> have[2000003];
int fa[2000003];
bool pd[2000003];
int getfather(int x) { return fa[x] == x ? x : fa[x] = getfather(fa[x]); }
inline void merge(int x, int y) {
  int fx = getfather(x), fy = getfather(y);
  fa[fx] = fy;
}
inline void add(int x, int y) { e[x].push_back(y); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) scanf("%d", &a[get(i, j)]);
  }
  for (int i = 1; i <= n * m; i++) fa[i] = i;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) b[j] = (asd){a[get(i, j)], get(i, j)};
    std::sort(b + 1, b + m + 1, cmp);
    int p = 0;
    for (int j = 1; j <= m; j++)
      if (j == 1 || b[j].a == b[j - 1].a) {
        add(p, b[j].id);
        if (j != 1) merge(b[j].id, b[j - 1].id);
      } else {
        add(b[j - 1].id, b[j].id);
        p = b[j - 1].id;
      }
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) b[i] = (asd){a[get(i, j)], get(i, j)};
    std::sort(b + 1, b + n + 1, cmp);
    int p = 0;
    for (int j = 1; j <= n; j++)
      if (j == 1 || b[j].a == b[j - 1].a) {
        add(p, b[j].id);
        if (j != 1) merge(b[j].id, b[j - 1].id);
      } else {
        add(b[j - 1].id, b[j].id);
        p = b[j - 1].id;
      }
  }
  have[0].push_back(0);
  for (int i = 1; i <= n * m; i++) {
    fa[i] = getfather(i);
    have[fa[i]].push_back(i);
  }
  for (int i = 0; i <= n * m; i++) {
    for (int j = 0; j < e[i].size(); j++)
      if (fa[i] != fa[e[i][j]]) {
        du[fa[e[i][j]]]++;
      }
  }
  int tot = 0;
  int he = 0, en = 1;
  d[1] = 0;
  while (he < en) {
    int ten = en;
    for (int i = he + 1; i <= ten; i++) {
      for (int k = 0; k < have[d[i]].size(); k++) {
        int x = have[d[i]][k];
        ans[x] = tot;
        for (int j = 0; j < e[x].size(); j++)
          if (fa[x] != fa[e[x][j]]) {
            du[fa[e[x][j]]]--;
            if (du[fa[e[x][j]]] == 0) {
              d[++en] = fa[e[x][j]];
            }
          }
      }
    }
    tot++;
    he = ten;
  }
  for (int i = 1; i <= n * m; i++)
    if (ans[i] == 0) return 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%d ", ans[get(i, j)]);
    printf("\n");
  }
  return 0;
}
