#include <bits/stdc++.h>
using namespace std;
const int MAXN = 250 + 10;
int a[MAXN][MAXN];
int r[MAXN], c[MAXN], row[MAXN * MAXN], col[MAXN * MAXN];
int n, m;
inline void init(void) {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      scanf("%d", &a[i][j]);
      r[i] = max(r[i], a[i][j]);
      c[j] = max(c[j], a[i][j]);
    }
  for (int i = 1; i <= n; ++i) row[r[i]] = 1;
  for (int j = 1; j <= m; ++j) col[c[j]] = 1;
}
int b[MAXN][MAXN];
struct element {
  int x, y;
  element() { x = y = 0; }
  element(int _x, int _y) : x(_x), y(_y) {}
};
queue<element> Q;
inline void work(void) {
  int posX = 0, posY = 0;
  for (int i = n * m; i >= 1; --i) {
    if (row[i]) ++posX;
    if (col[i]) ++posY;
    if (row[i] || col[i])
      b[posX][posY] = i;
    else
      b[Q.front().x][Q.front().y] = i, Q.pop();
    if (row[i])
      for (int i = posY - 1; i >= 1; --i) Q.push(element(posX, i));
    if (col[i])
      for (int i = posX - 1; i >= 1; --i) Q.push(element(i, posY));
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) printf("%d ", b[i][j]);
    printf("\n");
  }
}
int main() {
  init();
  work();
  return 0;
}
