#include <bits/stdc++.h>
using namespace std;
int x, y, n, m, i, j, l, r, la, mx, a[1010][1010], b[1010][1010], h[100010],
    w[100010], c[100010][2];
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  for (i = 1; i <= n; i++) {
    mx = 0;
    for (j = 1; j <= m; j++) mx = max(mx, a[i][j]);
    h[mx] = 1;
  }
  for (j = 1; j <= m; j++) {
    mx = 0;
    for (i = 1; i <= n; i++) mx = max(mx, a[i][j]);
    w[mx] = 1;
  }
  x = 0;
  y = 0;
  l = 1;
  for (i = n * m; i; i--) {
    x += h[i];
    y += w[i];
    if (h[i] || w[i])
      b[x][y] = i;
    else {
      b[c[l][0]][c[l][1]] = i;
      l++;
    }
    if (h[i])
      for (j = y - 1; j; j--) c[++r][0] = x, c[r][1] = j;
    if (w[i])
      for (j = x - 1; j; j--) c[++r][0] = j, c[r][1] = y;
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) printf("%d ", b[i][j]);
    puts("");
  }
}
