#include <bits/stdc++.h>
using namespace std;
const int maxn = 255;
int n, m, a[maxn][maxn], b[maxn][maxn];
bool chkr[maxn * maxn], chkc[maxn * maxn];
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]);
    }
    chkr[*max_element(a[i] + 1, a[i] + m + 1)] = 1;
  }
  for (int i = 1; i <= m; i++) {
    int mx = 0;
    for (int j = 1; j <= n; j++) mx = max(mx, a[j][i]);
    chkc[mx] = 1;
  }
  int p1 = 0, p2 = 0;
  queue<pair<int, int>> Q;
  for (int i = n * m; i; i--) {
    if (chkr[i]) p1++;
    if (chkc[i]) p2++;
    if (chkr[i] || chkc[i]) {
      b[p1][p2] = i;
      if (chkr[i]) {
        for (int j = p2 - 1; j; j--) Q.push({p1, j});
      }
      if (chkc[i]) {
        for (int j = p1 - 1; j; j--) Q.push({j, p2});
      }
    } else {
      auto p = Q.front();
      b[p.first][p.second] = i, Q.pop();
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", b[i][j]);
    }
    printf("\n");
  }
  return 0;
}
