#include <bits/stdc++.h>
using namespace std;
const int N = 3e2 + 10;
int a[N][N];
int stan[N][N];
int n, m;
int Num[N * N];
priority_queue<pair<int, pair<int, int> > > p;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    int Max = 0;
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      Max = max(Max, a[i][j]);
    }
    for (int j = 1; j <= m; j++) {
      if (Max == a[i][j]) Num[a[i][j]] += 1;
    }
  }
  for (int i = 1; i <= m; i++) {
    int Max = 0;
    for (int j = 1; j <= n; j++) {
      Max = max(Max, a[j][i]);
    }
    for (int j = 1; j <= n; j++) {
      if (a[j][i] == Max) Num[a[j][i]] += 2;
    }
  }
  int r = 0, c = 0;
  int cnt = n * m;
  bool fla1, fla2;
  for (int i = n * m; i >= 1; i--) {
    fla1 = false, fla2 = false;
    if (Num[i] == 3) {
      r++, c++;
      fla1 = fla2 = true;
    }
    if (Num[i] == 2) {
      c++;
      fla1 = true;
    }
    if (Num[i] == 1) {
      r++;
      fla2 = true;
    }
    if (fla1 == false && fla2 == false) {
      stan[p.top().second.first][p.top().second.second] = i;
      p.pop();
    } else {
      stan[r][c] = i;
      if (fla2) {
        for (int j = c - 1; j >= 1; j--) {
          p.push(make_pair(cnt--, make_pair(r, j)));
        }
      }
      if (fla1) {
        for (int j = r - 1; j >= 1; j--) {
          p.push(make_pair(cnt--, make_pair(j, c)));
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << stan[i][j] << ' ';
    }
    cout << '\n';
  }
  return 0;
}
