#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int maxn = 250 + 10;
int A[maxn][maxn];
int n, m;
int Rmax[maxn * maxn];
int Cmax[maxn * maxn];
inline void solve() {
  queue<pair<int, int> > q;
  int x, y;
  x = y = 0;
  for (auto e = (n * m); e >= (1); --e) {
    x += Rmax[e];
    y += Cmax[e];
    if (Rmax[e] || Cmax[e])
      A[x][y] = e;
    else {
      int qx, qy;
      tie(qx, qy) = q.front();
      A[qx][qy] = e;
      q.pop();
    }
    if (Rmax[e]) {
      for (auto i = (y - 1); i >= (1); --i) q.push({x, i});
    }
    if (Cmax[e]) {
      for (auto i = (x - 1); i >= (1); --i) q.push({i, y});
    }
  }
  for (auto i = (1); i <= (n); ++i) {
    for (auto j = (1); j <= (m); ++j) {
      printf("%d ", A[i][j]);
    }
    puts("");
  }
}
int main(void) {
  scanf("%d%d", &n, &m);
  for (auto i = (1); i <= (n); ++i) {
    for (auto j = (1); j <= (m); ++j) scanf("%d", &(A[i][j]));
  }
  for (auto i = (1); i <= (n); ++i) {
    int x = 0;
    for (auto j = (1); j <= (m); ++j) x = max(x, A[i][j]);
    Rmax[x]++;
  }
  for (auto j = (1); j <= (m); ++j) {
    int y = 0;
    for (auto i = (1); i <= (n); ++i) y = max(y, A[i][j]);
    Cmax[y]++;
  }
  solve();
  return 0;
}
