#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e9;
long long powm(long long a, long long p, long long m) {
  long long r = 1 % m;
  while (p) {
    if (p & 1) r = r * a % m;
    p >>= 1;
    a = a * a % m;
  }
  return r;
}
int a[1000000], n, m, row[1000000], col[1000000], uses[1000000];
vector<int> g[1000000];
int get(int ij, int v = 1) {
  if (uses[ij]) return uses[ij];
  int i = ij / m, j = ij % m;
  uses[ij] = max(v, max(row[i], col[j]) + 1);
  for (int k = 0; k < g[ij].size(); ++k)
    uses[ij] = max(uses[ij], get(g[ij][k], uses[ij]));
  return uses[ij];
}
void _set(int ij, int v) {
  if (uses[ij] <= 0) return;
  uses[ij] = -1;
  a[ij] = row[ij / m] = col[ij % m] = v;
  for (int k = 0; k < g[ij].size(); ++k) _set(g[ij][k], v);
}
int main() {
  scanf("%d%d", &n, &m);
  map<int, vector<pair<int, int> > > pos;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      scanf("%d", a + i * m + j);
      pos[a[i * m + j]].push_back(make_pair(i, j));
    }
  for (int i = 0; i < n; ++i) {
    map<int, int> tmp;
    for (int j = 0; j < m; ++j) {
      int t = a[i * m + j];
      if (tmp.count(t) > 0) {
        int p = tmp[t];
        g[i * m + j].push_back(i * m + p);
        g[i * m + p].push_back(i * m + j);
      }
      tmp[t] = j;
    }
  }
  for (int j = 0; j < m; ++j) {
    map<int, int> tmp;
    for (int i = 0; i < n; ++i) {
      int t = a[i * m + j];
      if (tmp.count(t) > 0) {
        int p = tmp[t];
        g[i * m + j].push_back(p * m + j);
        g[p * m + j].push_back(i * m + j);
      }
      tmp[t] = i;
    }
  }
  for (map<int, vector<pair<int, int> > >::iterator it = pos.begin();
       it != pos.end(); ++it) {
    for (vector<pair<int, int> >::iterator it2 = it->second.begin();
         it2 != it->second.end(); ++it2) {
      int v = get(it2->first * m + it2->second);
      if (v > 0) _set(it2->first * m + it2->second, v);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) printf("%d ", a[i * m + j]);
    puts("");
  }
  return 0;
}
