#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
long long ogrid[255][255], grid[255][255];
long long mxr[255], mxc[255];
bool rev_mxr[100005], rev_mxc[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  queue<pair<long long, long long> > unmarked_squares;
  long long row = 0, col = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cin >> ogrid[i][j];
      mxr[i] = max(mxr[i], ogrid[i][j]);
      mxc[j] = max(mxc[j], ogrid[i][j]);
    }
  }
  for (long long i = 1; i <= n; i++) rev_mxr[mxr[i]] = 1;
  for (long long j = 1; j <= m; j++) rev_mxc[mxc[j]] = 1;
  for (long long i = n * m; i >= 1; i--) {
    if (rev_mxr[i]) row++;
    if (rev_mxc[i]) col++;
    if ((rev_mxr[i]) || (rev_mxc[i]))
      grid[row][col] = i;
    else {
      pair<long long, long long> f = unmarked_squares.front();
      unmarked_squares.pop();
      long long x = f.first, y = f.second;
      grid[x][y] = i;
    }
    if (rev_mxr[i]) {
      for (long long y = col - 1; y >= 1; y--)
        unmarked_squares.push(make_pair(row, y));
    }
    if (rev_mxc[i]) {
      for (long long x = row - 1; x >= 1; x--)
        unmarked_squares.push(make_pair(x, col));
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) cout << grid[i][j] << " ";
    cout << "\n";
  }
}
