#include <bits/stdc++.h>
using namespace std;
int a[252][252], r[252], c[252], sol[252][252];
queue<pair<int, int>> q;
int main() {
  int n, m, i, j, x, l;
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      cin >> a[i][j], r[i] = max(r[i], a[i][j]), c[j] = max(c[j], a[i][j]);
  sort(r + 1, r + n + 1);
  sort(c + 1, c + m + 1);
  reverse(r + 1, r + n + 1);
  reverse(c + 1, c + m + 1);
  i = 0;
  j = 0;
  for (x = n * m; x >= 1; x--) {
    if (x == r[i + 1] && x == c[j + 1]) {
      i++;
      j++;
      sol[i][j] = x;
      for (l = i - 1; l >= 1; l--) q.push({l, j});
      for (l = j - 1; l >= 1; l--) q.push({i, l});
    } else if (x == r[i + 1]) {
      i++;
      sol[i][j] = x;
      for (l = j - 1; l >= 1; l--) q.push({i, l});
    } else if (x == c[j + 1]) {
      j++;
      sol[i][j] = x;
      for (l = i - 1; l >= 1; l--) q.push({l, j});
    } else {
      sol[q.front().first][q.front().second] = x;
      q.pop();
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) cout << sol[i][j] << " ";
    cout << '\n';
  }
  return 0;
}
