#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
const long long inf = 4e18;
const int infi = 2e9;
int i, j, n, m, k, qq = 1, fr, to, w, x, y, mod = 998244353;
char ch;
int a[250][250], ans[250][250];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  set<int> ver, gor;
  for (int i = 0; i < n; i++) {
    gor.insert(*max_element(a[i], a[i] + m));
  }
  for (int j = 0; j < m; j++) {
    int mx = -1;
    for (int i = 0; i < n; i++) mx = max(mx, a[i][j]);
    ver.insert(mx);
  }
  queue<pair<int, int> > q;
  int x = -1, y = -1;
  for (int num = n * m; num > 0; num--) {
    if (gor.count(num)) x++;
    if (ver.count(num)) y++;
    if (gor.count(num) || ver.count(num)) {
      ans[x][y] = num;
    } else {
      pair<long long, long long> c = q.front();
      q.pop();
      ans[c.first][c.second] = num;
    }
    if (gor.count(num)) {
      for (int i = y - 1; i >= 0; i--) q.push({x, i});
    }
    if (ver.count(num)) {
      for (int i = x - 1; i >= 0; i--) q.push({i, y});
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << ans[i][j] << ' ';
    }
    cout << endl;
  }
}
