#include <bits/stdc++.h>
using namespace std;
const int N = 300 + 5;
int n, m;
int b[N][N], a[N][N], r[N * N], c[N * N], p1[N], p2[N], dx[N * N], dy[N * N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (1); j < (m + 1); j++) {
      scanf("%d", &a[i][j]);
      p1[i] = max(p1[i], a[i][j]);
      p2[j] = max(p2[j], a[i][j]);
    }
  }
  for (int i = (1); i < (n + 1); i++) dx[p1[i]]++;
  for (int i = (1); i < (m + 1); i++) dy[p2[i]]++;
  int x, y;
  x = 0, y = 0;
  queue<pair<int, int> > q;
  for (int i = n * m; i >= 1; --i) {
    x += dx[i], y += dy[i];
    if (dx[i] + dy[i])
      b[x][y] = i;
    else {
      pair<int, int> t = q.front();
      q.pop();
      b[t.first][t.second] = i;
    }
    if (dx[i])
      for (int j = y - 1; j >= 1; --j) q.push(pair<int, int>(x, j));
    if (dy[i])
      for (int j = x - 1; j >= 1; --j) q.push(pair<int, int>(j, y));
  }
  for (int i = (1); i < (n + 1); i++) {
    for (int j = (1); j < (m + 1); j++) cout << b[i][j] << " ";
    cout << "\n";
  }
  return 0;
}
