#include <bits/stdc++.h>
using namespace std;
const int M = 255;
int read() {
  int x = 0, y = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') y = (ch == '-' ? -1 : 1), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * y;
}
int n, m, H[M], L[M], A[M][M], B[M][M];
struct node {
  int x, y;
};
queue<node> Q;
void Add(int x, int y, int v) {
  B[x][y] = v;
  if (x > 1 && !B[x - 1][y]) Q.push((node){x - 1, y});
  if (y > 1 && !B[x][y - 1]) Q.push((node){x, y - 1});
}
void solve() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) A[i][j] = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) H[i] = max(H[i], A[i][j]);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) L[i] = max(L[i], A[j][i]);
  sort(H + 1, H + n + 1), sort(L + 1, L + m + 1);
  int zzh = n, zzl = m, nh = 0, nl = 0;
  for (int i = n * m; i >= 1; i--) {
    if (i == H[zzh] && i == L[zzl]) {
      nh++, nl++;
      Add(nh, nl, i);
      zzh--, zzl--;
    } else if (i == H[zzh]) {
      nh++;
      Add(nh, nl, i);
      zzh--;
    } else if (i == L[zzl]) {
      nl++;
      Add(nh, nl, i);
      zzl--;
    } else {
      node u = Q.front();
      Q.pop();
      while (!Q.empty() && B[u.x][u.y]) u = Q.front(), Q.pop();
      Add(u.x, u.y, i);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%d ", B[i][j]);
    printf("\n");
  }
}
signed main() { solve(); }
