#include <bits/stdc++.h>
using namespace std;
const int N = 255;
int n, m, a[N][N];
int f[N][N], vn[N * N], vm[N * N];
pair<int, int> q[N * N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (int)(1); i <= (int)(n); i++)
    for (int j = (int)(1); j <= (int)(m); j++) scanf("%d", &a[i][j]);
  for (int i = (int)(1); i <= (int)(n); i++) {
    int v = 0;
    for (int j = (int)(1); j <= (int)(m); j++) v = max(v, a[i][j]);
    vn[v] = 1;
  }
  for (int i = (int)(1); i <= (int)(m); i++) {
    int v = 0;
    for (int j = (int)(1); j <= (int)(n); j++) v = max(v, a[j][i]);
    vm[v] = 1;
  }
  int h = 1, t = 0, x = 0, y = 0;
  for (int i = (int)(n * m); i >= (int)(1); i--) {
    x += vn[i];
    y += vm[i];
    if (vn[i] || vm[i])
      f[x][y] = i;
    else {
      assert(h <= t);
      pair<int, int> tmp = q[h++];
      f[tmp.first][tmp.second] = i;
    }
    if (vm[i])
      for (int i = (int)(x - 1); i >= (int)(1); i--)
        q[++t] = pair<int, int>(i, y);
    if (vn[i])
      for (int i = (int)(y - 1); i >= (int)(1); i--)
        q[++t] = pair<int, int>(x, i);
  }
  for (int i = (int)(1); i <= (int)(n); i++)
    for (int j = (int)(1); j <= (int)(m); j++)
      printf("%d%c", f[i][j], j == m ? '\n' : ' ');
}
