#include <bits/stdc++.h>
using namespace std;
int n, m, a[255][255], r[63000], c[63000], x, y, ans[255][255], qx[63000],
    qy[63000], ql, qr;
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);
  }
  for (int i = 1; i <= n; ++i) {
    int x = 0;
    for (int j = 1; j <= m; ++j) x = max(x, a[i][j]);
    r[x] = 1;
  }
  for (int j = 1; j <= m; ++j) {
    int x = 0;
    for (int i = 1; i <= n; ++i) x = max(x, a[i][j]);
    c[x] = 1;
  }
  for (int i = n * m; i; --i) {
    if (r[i] && c[i]) {
      ++x, ++y;
      ans[x][y] = i;
      for (int j = y - 1; j; --j) ++qr, qx[qr] = x, qy[qr] = j;
      for (int j = x - 1; j; --j) ++qr, qx[qr] = j, qy[qr] = y;
    } else if (r[i]) {
      ++x;
      ans[x][y] = i;
      for (int j = y - 1; j; --j) ++qr, qx[qr] = x, qy[qr] = j;
    } else if (c[i]) {
      ++y;
      ans[x][y] = i;
      for (int j = x - 1; j; --j) ++qr, qx[qr] = j, qy[qr] = y;
    } else {
      ++ql;
      ans[qx[ql]][qy[ql]] = i;
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j < m; ++j) printf("%d ", ans[i][j]);
    printf("%d\n", ans[i][m]);
  }
  return 0;
}
