#include <bits/stdc++.h>
void _print(int *a, int n) {}
using namespace std;
const int N = 300;
int n, m;
int a[N][N], h[N], v[N];
int ans[N][N];
signed main() {
  scanf("%d", &n), scanf("%d", &m);
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j) {
      scanf("%d", &a[i][j]);
      h[i] = max(h[i], a[i][j]);
      v[j] = max(v[j], a[i][j]);
    }
  sort(h, h + n, greater<int>());
  sort(v, v + m, greater<int>());
  int ph = 0, pv = 0;
  queue<pair<int, int> > q;
  for (int i = (n * m + 1) - 1; i >= (1); --i) {
    if (ph < n && i == h[ph + 1]) ph++;
    if (pv < m && i == v[pv + 1]) pv++;
    if (i == h[ph] || i == v[pv]) {
      ans[ph][pv] = i;
      if (i == h[ph])
        for (int i = (pv)-1; i >= (0); --i) q.push(make_pair(ph, i));
      if (i == v[pv])
        for (int i = (ph)-1; i >= (0); --i) q.push(make_pair(i, pv));
    } else {
      pair<int, int> p = q.front();
      q.pop();
      ans[p.first][p.second] = i;
    }
  }
  for (int i = (0); i < (n); ++i) {
    for (int _ = (0); _ < (m); ++_)
      printf("%d%c", ans[i][_], " \n"[_ == m - 1]);
  }
}
