#include <bits/stdc++.h>
using namespace std;
int n, m, a[300][300], ans[300][300];
int line[300 * 300], col[300 * 300];
struct par {
  int x, y;
} q[300 * 300];
int st = 0, ed = 0;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  for (int i = 1; i <= n; i++) {
    int ma = 0;
    for (int j = 1; j <= m; j++) ma = max(ma, a[i][j]);
    line[ma] = 1;
  }
  for (int j = 1; j <= m; j++) {
    int ma = 0;
    for (int i = 1; i <= n; i++) ma = max(ma, a[i][j]);
    col[ma] = 1;
  }
  int X = 0, Y = 0;
  for (int i = n * m; i >= 1; i--) {
    X += line[i], Y += col[i];
    if (line[i] || col[i])
      ans[X][Y] = i;
    else
      ans[q[st].x][q[st].y] = i, st++;
    if (line[i])
      for (int j = Y - 1; j >= 1; j--) q[ed++] = (par){X, j};
    if (col[i])
      for (int j = X - 1; j >= 1; j--) q[ed++] = (par){j, Y};
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%d ", ans[i][j]);
    printf("\n");
  }
}
