#include <bits/stdc++.h>
using namespace std;
static const int N = 1000000;
struct node {
  int data;
  node *next;
};
struct par {
  int val;
  int rb;
};
bool cmp(par a, par b) { return (a.val < b.val); }
node *s[2][N];
int t[N];
int u[N];
int l[N];
int o[N];
int d[N];
par p[N];
void connect(int x, int y, int k) {
  node *tmp = new node;
  tmp->data = y;
  tmp->next = s[k][x];
  s[k][x] = tmp;
}
void dfs(int c, int k) {
  o[c] = k;
  node *tmp = s[0][c];
  while (tmp) {
    if (o[tmp->data] == -1) dfs(tmp->data, k);
    tmp = tmp->next;
  }
}
void dfs2(int c, int val) {
  d[c] = 1;
  t[c] = val;
  node *tmp = s[0][c];
  while (tmp) {
    if (!d[tmp->data]) dfs2(tmp->data, val);
    tmp = tmp->next;
  }
}
int main() {
  int n, m;
  cin >> n;
  cin >> m;
  for (int i = 0; i < n * m; i++) scanf("%i", &t[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      p[j].val = t[i * m + j];
      p[j].rb = i * m + j;
    }
    sort(p, p + m, cmp);
    for (int i = 0; i < m - 1; i++) {
      if (p[i].val == p[i + 1].val) {
        connect(p[i].rb, p[i + 1].rb, 0);
        connect(p[i + 1].rb, p[i].rb, 0);
      } else
        connect(p[i].rb, p[i + 1].rb, 1);
    }
  }
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) {
      p[i].val = t[i * m + j];
      p[i].rb = i * m + j;
    }
    sort(p, p + n, cmp);
    for (int i = 0; i < n - 1; i++) {
      if (p[i].val == p[i + 1].val) {
        connect(p[i].rb, p[i + 1].rb, 0);
        connect(p[i + 1].rb, p[i].rb, 0);
      } else
        connect(p[i].rb, p[i + 1].rb, 1);
    }
  }
  for (int i = 0; i < n * m; i++) o[i] = -1;
  for (int i = 0; i < n * m; i++)
    if (o[i] == -1) dfs(i, i);
  for (int i = 0; i < n * m; i++) {
    node *tmp = s[1][i];
    while (tmp) {
      u[o[tmp->data]]++;
      tmp = tmp->next;
    }
  }
  for (int i = 0; i < n * m; i++) {
    node *tmp = s[1][i];
    while (tmp) {
      if (i != o[i] || tmp->data != o[tmp->data])
        connect(o[i], o[tmp->data], 1);
      tmp = tmp->next;
    }
  }
  queue<int> q;
  for (int i = 0; i < n * m; i++)
    if (o[i] == i && !u[i]) {
      l[i] = 1;
      q.push(i);
    }
  int pc = 0;
  int big = 0;
  for (int i = 0; i < n * m; i++)
    if (u[i] > big) big = u[i];
  while (!q.empty()) {
    pc++;
    int c = q.front();
    q.pop();
    dfs2(c, l[c]);
    node *tmp = s[1][c];
    while (tmp) {
      u[tmp->data]--;
      l[tmp->data] = max(l[tmp->data], l[c] + 1);
      if (!u[tmp->data]) q.push(tmp->data);
      tmp = tmp->next;
    }
  }
  for (int i = 0; i < n * m; i++)
    if (u[i] > big) big = u[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) printf("%i ", t[i * m + j]);
    printf("\n");
  }
  return 0;
}
