#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  write(a);
  puts("");
}
inline void wri(long long a) {
  write(a);
  putchar(' ');
}
int n, m;
int nl[255], ml[255], nll = 2, mll = 2;
int ans[255][255];
queue<pair<int, int> > q;
void check(int x, int y) {
  if (x >= 1 && x <= n && y >= 1 && y <= m && ans[x][y] == 0 &&
      ((ans[x - 1][y] != 0 && ans[x][y + 1] != 0) ||
       (ans[x + 1][y] != 0 && ans[x][y - 1] != 0)))
    q.push(make_pair(x, y));
}
bool cmp(int a, int b) { return a > b; }
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int x = read();
      nl[i] = max(nl[i], x);
      ml[j] = max(ml[j], x);
    }
  }
  sort(nl + 1, nl + n + 1, cmp);
  sort(ml + 1, ml + m + 1, cmp);
  ans[1][1] = n * m;
  for (int i = n * m - 1; i >= 1; i--) {
    if (nl[nll] == i && ml[mll] == i) {
      ans[nll][mll] = i;
      check(nll, mll - 1);
      check(nll - 1, mll);
      check(nll, mll + 1);
      check(nll + 1, mll);
      nll++;
      mll++;
    } else if (nl[nll] == i) {
      ans[nll][mll - 1] = i;
      check(nll, mll - 2);
      check(nll - 1, mll - 1);
      check(nll, mll);
      check(nll + 1, mll - 1);
      nll++;
    } else if (ml[mll] == i) {
      ans[nll - 1][mll] = i;
      check(nll - 1, mll - 1);
      check(nll - 2, mll);
      check(nll - 1, mll + 1);
      check(nll, mll);
      mll++;
    } else {
      int x = q.front().first, y = q.front().second;
      q.pop();
      ans[x][y] = i;
      check(x, y - 1);
      check(x - 1, y);
      check(x, y + 1);
      check(x + 1, y);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      wri(ans[i][j]);
    }
    cout << endl;
  }
  return 0;
}
