#include <bits/stdc++.h>
using pii = std::pair<int, int>;
const int N = 3e2 + 10;
inline int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
int a[N], b[N], t[N * N], c[N][N];
int main() {
  int n = read(), m = read();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      int x = read();
      a[i] = std::max(a[i], x);
      b[j] = std::max(b[j], x);
    }
  for (int i = 1; i <= n; ++i) t[a[i]] ^= 1;
  for (int i = 1; i <= m; ++i) t[b[i]] ^= 2;
  int x = 0, y = 0;
  std::queue<pii> que;
  for (int i = n * m; i >= 1; --i)
    if (t[i]) {
      x += t[i] & 1, y += t[i] >> 1 & 1, c[x][y] = i;
      for (int i = y - 1; i >= 1; --i)
        if (c[x][i])
          break;
        else
          que.push(std::make_pair(x, i));
      for (int i = x - 1; i >= 1; --i)
        if (c[i][y])
          break;
        else
          que.push(std::make_pair(i, y));
    } else {
      int x = que.front().first;
      int y = que.front().second;
      c[x][y] = i, que.pop();
    }
  for (int i = 1; i <= n; ++i, putchar('\n'))
    for (int j = 1; j <= m; ++j) printf("%d ", c[i][j]);
  return 0;
}
