#include <bits/stdc++.h>
using namespace std;
vector<int> ans[1000001];
map<int, vector<pair<int, int> > > mm;
int row_max[1000001], col_max[1000001];
int n, m;
int main() {
  int i, j, x;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m + 1; j++) ans[i].push_back(0);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      scanf("%d", &x);
      mm[x].push_back(make_pair(i, j));
    }
  map<int, vector<pair<int, int> > >::iterator t;
  for (t = mm.begin(); t != mm.end(); t++) {
    vector<pair<int, int> > v = t->second;
    for (i = 0; i < v.size(); i++) {
      int x = v[i].first, y = v[i].second;
      ans[x][y] = max(row_max[x], col_max[y]) + 1;
    }
    for (i = 0; i < v.size(); i++) {
      int x = v[i].first, y = v[i].second;
      row_max[x] = max(row_max[x], ans[x][y]);
      col_max[y] = max(col_max[y], ans[x][y]);
    }
    bool f = true;
    while (f) {
      f = false;
      for (i = 0; i < v.size(); i++) {
        int x = v[i].first, y = v[i].second;
        int k = max(row_max[x], col_max[y]);
        if (k > ans[x][y]) {
          ans[x][y] = k;
          row_max[x] = max(row_max[x], k);
          col_max[y] = max(col_max[y], k);
          f = true;
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (j != 1) printf(" ");
      printf("%d", ans[i][j]);
    }
    printf("\n");
  }
  return 0;
}
