#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int a[255][255], n, m, cnt, ans[255][255];
pair<int, int> p[255 * 255], used[100005];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= n; i++) {
    int maxi = 0;
    for (int j = 1; j <= m; j++) maxi = max(maxi, a[i][j]);
    p[maxi].first = 1;
  }
  for (int i = 1; i <= m; i++) {
    int maxi = 0;
    for (int j = 1; j <= n; j++) maxi = max(maxi, a[j][i]);
    p[maxi].second = 1;
  }
  int h = 0, w = 0, l = 0;
  for (int i = n * m; i >= 1; i--) {
    bool ff = 0;
    if (p[i].first && !p[i].second) {
      h++;
      ff = 1;
      ans[h][w] = i;
      for (int j = w - 1; j >= 1; j--) {
        used[++cnt] = make_pair(h, j);
      }
    }
    if (p[i].second && !p[i].first) {
      w++;
      ff = 1;
      ans[h][w] = i;
      for (int j = h - 1; j >= 1; j--) {
        used[++cnt] = make_pair(j, w);
      }
    }
    if (p[i].first && p[i].second) {
      w++;
      h++;
      ff = 1;
      ans[h][w] = i;
      for (int j = h - 1; j >= 1; j--) {
        used[++cnt] = make_pair(j, w);
      }
      for (int j = w - 1; j >= 1; j--) {
        used[++cnt] = make_pair(h, j);
      }
    }
    if (!ff) {
      ++l;
      ans[used[l].first][used[l].second] = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cout << ans[i][j] << ' ';
    cout << '\n';
  }
  return 0;
}
