#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> input(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> input[i][j];
    }
  }
  unordered_set<int> x, y;
  for (int i = 0; i < n; ++i) {
    int mx = INT_MIN;
    for (int j = 0; j < m; ++j) {
      mx = max(mx, input[i][j]);
    }
    x.insert(mx);
  }
  for (int j = 0; j < m; ++j) {
    int mx = INT_MIN;
    for (int i = 0; i < n; ++i) {
      mx = max(mx, input[i][j]);
    }
    y.insert(mx);
  }
  queue<pair<int, int>> pos;
  vector<vector<int>> ans(n, vector<int>(m));
  int X = -1, Y = -1;
  for (int i = n * m; i >= 1; --i) {
    if (x.count(i)) {
      X++;
    }
    if (y.count(i)) {
      Y++;
    }
    if (x.count(i)) {
      for (int i = Y - 1; i >= 0; --i) {
        pos.emplace(X, i);
      }
    }
    if (y.count(i)) {
      for (int i = X - 1; i >= 0; --i) {
        pos.emplace(i, Y);
      }
    }
    if (x.count(i) || y.count(i)) {
      ans[X][Y] = i;
    } else {
      int a, b;
      tie(a, b) = pos.front();
      pos.pop();
      ans[a][b] = i;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cout << ans[i][j] << " ";
    }
    cout << "\n";
  }
}
