#include <bits/stdc++.h>
using namespace std;
const int N = 250 + 5, M = N * N;
int n, m, a[N][N];
int r[M], c[M], X, Y, mat[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]);
  }
  for (int i = 1; i <= n; ++i) {
    int Max = 0;
    for (int j = 1; j <= m; ++j) Max = max(Max, a[i][j]);
    r[Max] = 1;
  }
  for (int j = 1; j <= m; ++j) {
    int Max = 0;
    for (int i = 1; i <= n; ++i) Max = max(Max, a[i][j]);
    c[Max] = 1;
  }
  for (int i = n * m; i >= 1; --i) {
    X += r[i];
    Y += c[i];
    if (r[i] || c[i])
      mat[X][Y] = i;
    else {
      pair<int, int> now = q.front();
      q.pop();
      int x = now.first, y = now.second;
      mat[x][y] = i;
    }
    if (r[i])
      for (int j = Y - 1; j >= 1; --j) q.push(make_pair(X, j));
    if (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%c", mat[i][j], (j == m) ? '\n' : ' ');
  return 0;
}
