#include <bits/stdc++.h>
using namespace std;
const int N = 255;
int n, m;
int a[N][N];
queue<pair<int, int>> q;
int rmx[N * N], cmx[N * N];
int ans[N][N];
void Add(int x, int y) { q.push(make_pair(x, y)); }
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]);
  int mx;
  for (int i = 1; i <= n; i++) {
    mx = 0;
    for (int j = 1; j <= m; j++) mx = max(mx, a[i][j]);
    rmx[mx] = 1;
  }
  for (int j = 1; j <= m; j++) {
    mx = 0;
    for (int i = 1; i <= n; i++) mx = max(mx, a[i][j]);
    cmx[mx] = 1;
  }
  int X = 0, Y = 0;
  for (int i = n * m; i >= 1; i--) {
    if (rmx[i] && cmx[i]) {
      X++;
      Y++;
      ans[X][Y] = i;
      for (int j = Y - 1; j >= 1; j--) Add(X, j);
      for (int j = X - 1; j >= 1; j--) Add(j, Y);
    }
    if (!rmx[i] && cmx[i]) {
      Y++;
      ans[X][Y] = i;
      for (int j = X - 1; j >= 1; j--) Add(j, Y);
    }
    if (rmx[i] && !cmx[i]) {
      X++;
      ans[X][Y] = i;
      for (int j = Y - 1; j >= 1; j--) Add(X, j);
    }
    if (!rmx[i] && !cmx[i]) {
      pair<int, int> pos = q.front();
      q.pop();
      ans[pos.first][pos.second] = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%d ", ans[i][j]);
    printf("\n");
  }
}
