#include <bits/stdc++.h>
using namespace std;
int n, m, Rm[300], Cm[300], a[300][300];
bool isR[62510], isC[62510];
queue<pair<int, int> > q;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1, w; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%d", &w);
      Rm[i] = max(Rm[i], w), Cm[j] = max(Cm[j], w);
    }
  for (int i = 1; i <= n; i++) isR[Rm[i]] = true;
  for (int j = 1; j <= m; j++) isC[Cm[j]] = true;
  for (int x = n * m, sx = 0, sy = 0; x >= 1; x--) {
    if (isR[x]) sx++;
    if (isC[x]) sy++;
    if (isR[x] || isC[x])
      a[sx][sy] = x;
    else
      a[q.front().first][q.front().second] = x, q.pop();
    if (isR[x])
      for (int j = sy - 1; j >= 1; j--) q.push(make_pair(sx, j));
    if (isC[x])
      for (int i = sx - 1; i >= 1; i--) q.push(make_pair(i, sy));
  }
  for (int i = 1; i <= n; i++, puts(""))
    for (int j = 1; j <= m; j++) printf("%d ", a[i][j]);
}
