#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
using ll = long long;
const int maxn = 255;
const int inf = 1e9;
int n, m;
int a[maxn][maxn];
int b[maxn][maxn];
void print() {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << b[i][j] << " ";
    }
    cout << "\n";
  }
}
bool used[maxn * maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  vector<int> rmax(n), cmax(m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      rmax[i] = max(rmax[i], a[i][j]);
      cmax[j] = max(cmax[j], a[i][j]);
    }
  }
  rmax.push_back(inf);
  cmax.push_back(inf);
  sort(rmax.begin(), rmax.end());
  sort(cmax.begin(), cmax.end());
  {
    int ri = 0;
    int ci = 0;
    while (ri < n && ci < m) {
      int val = min(rmax[ri], cmax[ci]);
      b[ri][ci] = val;
      used[val] = true;
      if (rmax[ri] == val) ri++;
      if (cmax[ci] == val) ci++;
    }
  }
  {
    int ri = 0;
    int ci = 0;
    int at = 1;
    while (ri < n && ci < m) {
      int val = min(rmax[ri], cmax[ci]);
      b[ri][ci] = val;
      used[val] = true;
      for (int j = m - 1; j >= 0; j--) {
        if (!b[ri][j]) {
          while (used[at]) at++;
          b[ri][j] = at;
          used[at] = true;
        }
      }
      for (int i = n - 1; i >= 0; i--) {
        if (!b[i][ci]) {
          while (used[at]) at++;
          b[i][ci] = at;
          used[at] = true;
        }
      }
      if (rmax[ri] == val) ri++;
      if (cmax[ci] == val) ci++;
    }
  }
  print();
  return 0;
}
