#include <bits/stdc++.h>
using namespace std;
const int MX = 250 + 5;
int n, m, A[MX][MX], B[MX][MX], R[MX], C[MX];
void inline upmx(int& x, int y) {
  if (y > x) x = y;
}
void solve() {
  cin >> n >> m;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j) cin >> A[i][j];
  for (int i = (0); i < (n); ++i) {
    int r = 0;
    for (int j = (0); j < (m); ++j) upmx(r, A[i][j]);
    R[i] = r;
  }
  for (int j = (0); j < (m); ++j) {
    int c = 0;
    for (int i = (0); i < (n); ++i) upmx(c, A[i][j]);
    C[j] = c;
  }
  sort(R, R + n, greater<int>());
  sort(C, C + m, greater<int>());
  int i = 0, j = 0;
  queue<pair<int, int> > q;
  for (int x = (n * m); x >= (1); --x) {
    bool r = 0, c = 0;
    if (x == R[i]) {
      ++i;
      r = 1;
    }
    if (x == C[j]) {
      ++j;
      c = 1;
    }
    if (r || c) {
      B[i - 1][j - 1] = x;
    } else {
      auto [qi, qj] = q.front();
      q.pop();
      B[qi][qj] = x;
    }
    if (r) {
      for (int qj = (j - 1) - 1; qj >= (0); --qj) q.emplace(i - 1, qj);
    }
    if (c) {
      for (int qi = (i - 1) - 1; qi >= (0); --qi) q.emplace(qi, j - 1);
    }
  }
  for (int bi = (0); bi < (n); ++bi) {
    for (int bj = (0); bj < (m); ++bj) cout << B[bi][bj] << ' ';
    cout << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
