#include <bits/stdc++.h>
using namespace std;
const int N = 255;
int a[N][N], b[N][N], n, m;
bool rmx[N * N], cmx[N * N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  for (int i = 1; i <= n; i++) {
    int mx = 0;
    for (int j = 1; j <= m; j++) mx = max(mx, a[i][j]);
    rmx[mx] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int mx = 0;
    for (int j = 1; j <= n; j++) mx = max(mx, a[j][i]);
    cmx[mx] = 1;
  }
  int r = 0, c = 0;
  queue<pair<int, int> > q;
  for (int i = n * m; i; i--) {
    if (rmx[i]) ++r;
    if (cmx[i]) ++c;
    if (rmx[i] || cmx[i]) {
      b[r][c] = i;
      if (rmx[i])
        for (int j = c - 1; j; j--) q.push(make_pair(r, j));
      if (cmx[i])
        for (int j = r - 1; j; j--) q.push(make_pair(j, c));
    } else {
      pair<int, int> t = q.front();
      q.pop();
      b[t.first][t.second] = i;
    }
  }
  for (int i = 1; i <= n; i++, cout << '\n')
    for (int j = 1; j <= m; j++) cout << b[i][j] << ' ';
  return 0;
}
