#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
int n, m, x, y, a[255][255], res[255][255];
int r[255], c[255];
queue<pair<int, int> > q;
bool bx[255 * 255], by[255 * 255];
signed main() {
  n = read(), m = read();
  for (register int i = (1); i <= (n); ++i)
    for (register int j = (1); j <= (m); ++j)
      a[i][j] = read(), r[i] = max(r[i], a[i][j]), c[j] = max(c[j], a[i][j]);
  for (register int i = (1); i <= (n); ++i) bx[r[i]] = 1;
  for (register int i = (1); i <= (m); ++i) by[c[i]] = 1;
  for (register int i = (n * m); i >= (1); --i) {
    if (bx[i]) ++x;
    if (by[i]) ++y;
    if (!bx[i] && !by[i]) {
      pair<int, int> u = q.front();
      q.pop();
      res[u.first][u.second] = i;
      continue;
    }
    res[x][y] = i;
    if (bx[i]) {
      for (register int j = (y - 1); j >= (1); --j) q.push(make_pair(x, j));
    }
    if (by[i]) {
      for (register int j = (x - 1); j >= (1); --j) q.push(make_pair(j, y));
    }
  }
  for (register int i = (1); i <= (n); ++i)
    for (register int j = (1); j <= (m); ++j)
      cout << res[i][j] << " \n"[j == m];
  return 0;
}
