#include <bits/stdc++.h>
using namespace std;
struct data {
  int x, y;
} d[int(300 + 5) * 4];
int N, M, a[int(300 + 5)][int(300 + 5)], b[int(300 + 5)][int(300 + 5)], x, y,
    num;
int R[int(300 + 5)], C[int(300 + 5)], cnt[int(300 + 5) * int(300 + 5)];
inline void read(int &x) {
  x = 0;
  bool f = 0;
  char ch = getchar();
  for (; !(ch >= '0' && ch <= '9'); ch = getchar()) f |= ch == '-';
  for (; (ch >= '0' && ch <= '9'); ch = getchar())
    x = (x << 3) + (x << 1) + (ch ^ 48);
  x = f ? -x : x;
}
void sol(int i, int j) {
  for (int k = j; k >= 1; --k) {
    if (b[i][k]) continue;
    while (cnt[num] == 0 && num > 0) --num;
    b[i][k] = num;
    cnt[num] = 0;
    --num;
  }
  for (int k = i; k >= 1; --k) {
    if (b[k][j]) continue;
    while (cnt[num] == 0 && num > 0) --num;
    b[k][j] = num;
    cnt[num] = 0;
    --num;
  }
}
int main() {
  read(N);
  read(M);
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= M; ++j)
      read(a[i][j]), R[i] = ((R[i]) > (a[i][j]) ? (R[i]) : (a[i][j])),
                     C[j] = ((C[j]) > (a[i][j]) ? (C[j]) : (a[i][j])),
                     cnt[(i - 1) * M + j] = 1;
  }
  sort(R + 1, R + 1 + N);
  sort(C + 1, C + 1 + M);
  for (int i = 1; i <= N / 2; ++i) swap(R[i], R[N - i + 1]);
  for (int i = 1; i <= M / 2; ++i) swap(C[i], C[M - i + 1]);
  for (int i = 1; i <= N; ++i) cnt[R[i]] = 0;
  for (int i = 1; i <= M; ++i) cnt[C[i]] = 0;
  x = 1;
  y = 1;
  num = 0;
  for (; x <= N || y <= M;) {
    if (x != N + 1 || y != M + 1) {
      if (R[x] == C[y]) {
        b[x][y] = R[x];
        cnt[R[x]] = 0;
        d[++num] = (data){x, y};
        ++x;
        ++y;
      } else if (R[x] < C[y]) {
        b[x - 1][y] = C[y];
        d[++num] = (data){x - 1, y};
        cnt[C[y]] = 0;
        ++y;
      } else {
        b[x][y - 1] = R[x];
        d[++num] = (data){x, y - 1};
        cnt[R[x]] = 0;
        ++x;
      }
    }
  }
  num = N * M;
  while (cnt[num] == 0 && num > 0) --num;
  for (int i = 1, j = 1, l = 1; num;) {
    if (d[l].x + 1 == d[l + 1].x && d[l].y + 1 == d[l + 1].y) {
      ++i;
      ++j;
      sol(i, j);
      ++l;
      continue;
    } else {
      if (d[l].x + 1 == d[l + 1].x && d[l].y == d[l + 1].y) {
        while (d[l].x + 1 == d[l + 1].x && d[l].y == d[l + 1].y) ++l;
        int x = d[l].x, y = d[l].y;
        for (int k = i + 1; k <= x; ++k) {
          for (int u = y - 1; u >= 1; --u) {
            if (b[k][u]) continue;
            while (cnt[num] == 0 && num > 0) --num;
            b[k][u] = num;
            cnt[num] = 0;
            --num;
          }
        }
        i = x;
        j = y;
      } else {
        while (d[l].x == d[l + 1].x && d[l].y + 1 == d[l + 1].y) ++l;
        int x = d[l].x, y = d[l].y;
        for (int k = j + 1; k <= y; ++k) {
          for (int u = x - 1; u >= 1; --u) {
            if (b[u][k]) continue;
            while (cnt[num] == 0 && num > 0) --num;
            b[u][k] = num;
            cnt[num] = 0;
            --num;
          }
        }
        i = x;
        j = y;
      }
    }
  }
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= M; ++j) printf("%d%c", b[i][j], j == M ? '\n' : ' ');
  }
  return 0;
}
