#include <bits/stdc++.h>
int read() {
  static int c, x;
  while ((c = getchar()) < 48) {
  }
  x = c & 15;
  while ((c = getchar()) >= 48) x = x * 10 + (c & 15);
  return x;
}
bool vx[260 * 260], vy[260 * 260];
int qx[260 * 260], qy[260 * 260];
int a[260][260];
int main() {
  const int n = read(), m = read();
  for (int i = 1; i <= n; ++i) {
    int mx = 0;
    for (int j = 1; j <= m; ++j) {
      a[i][j] = read();
      if (a[i][j] > mx) mx = a[i][j];
    }
    vx[mx] = true;
  }
  for (int i = 1; i <= m; ++i) {
    int mx = 0;
    for (int j = 1; j <= n; ++j) {
      if (a[j][i] > mx) mx = a[j][i];
    }
    vy[mx] = true;
  }
  for (int i = n * m, x = 0, y = 0, hd = 1, tl = 0; i; --i) {
    if (vx[i]) ++x;
    if (vy[i]) ++y;
    if (vx[i] || vy[i]) {
      a[x][y] = i;
    } else {
      a[qx[hd]][qy[hd]] = i;
      ++hd;
    }
    if (vx[i]) {
      for (int j = y; --j;) {
        ++tl;
        qx[tl] = x;
        qy[tl] = j;
      }
    }
    if (vy[i]) {
      for (int j = x; --j;) {
        ++tl;
        qx[tl] = j;
        qy[tl] = y;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      printf("%d ", a[i][j]);
    }
    putchar(10);
  }
  return 0;
}
