#include <bits/stdc++.h>
using namespace std;
int n, m, a[260][260];
int HANG[260], LIE[260];
bool HM[62510], LM[62510];
queue<pair<int, int> > que;
inline int read() {
  int x = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return w ? -x : x;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      a[i][j] = read();
      HANG[i] = max(HANG[i], a[i][j]);
      LIE[j] = max(LIE[j], a[i][j]);
    }
  for (int i = 1; i <= n; i++) HM[HANG[i]] = 1;
  for (int i = 1; i <= m; i++) LM[LIE[i]] = 1;
  int nowx = 0, nowy = 0;
  for (int i = n * m; i; i--) {
    if (HM[i]) nowx++;
    if (LM[i]) nowy++;
    if (HM[i] || LM[i]) {
      a[nowx][nowy] = i;
    } else {
      a[que.front().first][que.front().second] = i;
      que.pop();
    }
    if (HM[i])
      for (int j = nowy - 1; j; j--) que.push(make_pair(nowx, j));
    if (LM[i])
      for (int j = nowx - 1; j; j--) que.push(make_pair(j, nowy));
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) printf("%d%c", a[i][j], " \n"[j == m]);
}
