#include <bits/stdc++.h>
using namespace std;
const int mxn = 250;
int n, m;
int a[mxn][mxn];
int mx[mxn * mxn], my[mxn * mxn];
int qx[mxn * mxn], qy[mxn * mxn];
int fx[mxn * mxn], fy[mxn * mxn];
int ql, qr;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int x;
      cin >> x;
      x--;
      mx[i] = max(mx[i], x);
      my[j] = max(my[j], x);
    }
  for (int i = 0; i < n; i++) fx[mx[i]] = 1;
  for (int i = 0; i < m; i++) fy[my[i]] = 1;
  for (int i = n * m - 1, x = -1, y = -1; ~i; i--) {
    x += fx[i], y += fy[i];
    if (fx[i] || fy[i])
      a[x][y] = i + 1;
    else
      a[qx[ql]][qy[ql]] = i + 1, ql++;
    if (fx[i])
      for (int j = y - 1; ~j; j--) qx[qr] = x, qy[qr] = j, qr++;
    if (fy[i])
      for (int j = x - 1; ~j; j--) qx[qr] = j, qy[qr] = y, qr++;
  }
  for (int i = 0; i < n; i++) {
    cout << a[i][0];
    for (int j = 1; j < m; j++) cout << " " << a[i][j];
    cout << '\n';
  }
  return 0;
}
