#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const long long mod = 1e9 + 7;
inline long long gcd(long long a, long long b) {
  return !b ? a : gcd(b, a % b);
}
inline long long q_pow(long long a, long long x) {
  long long ans = 1, tmp = a;
  while (x) {
    if (x & 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    x >>= 1;
  }
  return ans;
}
template <typename T>
inline void re(T &N) {
  int f = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') f = -1;
  N = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') N = N * 10 + c - '0';
  N *= f;
}
int m, n, t = 1, st, en;
int a[300][300], b[300][300];
int row[300], col[300];
pair<int, int> sta[300 * 300];
pair<int, pair<int, int> > ins[N];
int cnt;
int main() {
  re(m);
  re(n);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) re(a[i][j]);
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) row[i] = max(row[i], a[i][j]);
  for (int j = 1; j <= n; j++)
    for (int i = 1; i <= m; i++) col[j] = max(col[j], a[i][j]);
  for (int i = 1; i <= m; i++) sta[row[i]].first = 1;
  for (int i = 1; i <= n; i++) sta[col[i]].second = 1;
  int r = 0, c = 0;
  for (int i = m * n; i >= 1; i--) {
    if (sta[i].first && sta[i].second) {
      r++;
      c++;
      b[r][c] = i;
    } else if (sta[i].first) {
      r++;
      b[r][c] = i;
    } else if (sta[i].second) {
      c++;
      b[r][c] = i;
    }
  }
  sort(row + 1, row + m + 1, greater<int>());
  sort(col + 1, col + n + 1, greater<int>());
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++)
      if (!b[i][j]) ins[++cnt] = {min(row[i], col[j]), {i, j}};
  sort(ins + 1, ins + cnt + 1, greater<pair<int, pair<int, int> > >());
  cnt = 0;
  for (int i = m * n; i >= 1; i--)
    if (!sta[i].first && !sta[i].second) {
      cnt++;
      b[ins[cnt].second.first][ins[cnt].second.second] = i;
    }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= n; j++) printf("%d%c", b[i][j], " \n"[j == n]);
}
