#include <bits/stdc++.h>
using namespace std;
const int N = 260;
int n, m, a[N][N], maxh[N], maxc[N], is_h[N * N], is_c[N * N], ans[N][N];
queue<pair<int, int> > q;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j)
      scanf("%d", &a[i][j]), maxh[i] = max(maxh[i], a[i][j]),
                             maxc[j] = max(maxc[j], a[i][j]);
  }
  for (int i = 1; i <= n; ++i) is_h[maxh[i]] = 1;
  for (int i = 1; i <= m; ++i) is_c[maxc[i]] = 1;
  int x = 0, y = 0;
  for (int i = n * m; i >= 1; --i) {
    if (is_h[i]) ++x;
    if (is_c[i]) ++y;
    if (is_h[i] || is_c[i]) {
      ans[x][y] = i;
    } else {
      ans[q.front().first][q.front().second] = i;
      q.pop();
    }
    if (is_h[i]) {
      for (int j = y - 1; j >= 1; --j) q.push(make_pair(x, j));
    }
    if (is_c[i]) {
      for (int j = x - 1; j >= 1; --j) q.push(make_pair(j, y));
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) printf("%d ", ans[i][j]);
    puts("");
  }
  return 0;
}
