#include <bits/stdc++.h>
using namespace std;
const int MAXN = 250 + 7;
int a[MAXN][MAXN], ans[MAXN][MAXN];
bool rmax[MAXN * MAXN], cmax[MAXN * MAXN], vis[MAXN * MAXN];
bool canr[MAXN], canc[MAXN];
int main() {
  int n, m;
  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]);
    rmax[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]);
    cmax[MAX] = 1;
  }
  int x = 0, y = 0;
  queue<pair<int, int> > pos;
  for (int num = n * m; num >= 1; num--) {
    x += rmax[num];
    y += cmax[num];
    if (rmax[num] || cmax[num]) {
      ans[x][y] = num;
    } else {
      pair<int, int> p = pos.front();
      pos.pop();
      ans[p.first][p.second] = num;
    }
    if (rmax[num]) {
      canr[x] = 1;
      for (int j = y - 1; j >= 1; j--)
        if (canc[j]) pos.push({x, j});
      for (int j = y + 1; j <= m; j++)
        if (canc[j]) pos.push({x, j});
    }
    if (cmax[num]) {
      canc[y] = 1;
      for (int i = x - 1; i >= 1; i--)
        if (canr[i]) pos.push({i, y});
      for (int i = x + 1; i <= n; i++)
        if (canr[i]) pos.push({i, y});
    }
  }
  for (int i = 1; i <= n; i++, puts(""))
    for (int j = 1; j <= m; j++) printf("%d ", ans[i][j]);
  return 0;
}
