#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int maxn = 2e5 + 22;
int n, m;
int a[300][300], ans[300][300];
bool vis1[maxn], vis2[maxn], us[maxn];
set<int> s;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int maxi = 0;
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
      maxi = max(maxi, a[i][j]);
    }
    vis1[maxi] = 1;
    s.insert(maxi);
  }
  for (int j = 1; j <= m; j++) {
    int maxi = 0;
    for (int i = 1; i <= n; i++) {
      maxi = max(maxi, a[i][j]);
    }
    vis2[maxi] = 1;
    s.insert(maxi);
  }
  int sx = 0, sy = 0;
  set<int>::iterator it = s.end();
  while (1) {
    it--;
    int tmp = *it;
    if (vis1[tmp] && vis2[tmp]) {
      sx++;
      sy++;
    } else if (vis1[tmp] && !vis2[tmp]) {
      sx++;
    } else {
      sy++;
    }
    ans[sx][sy] = tmp;
    us[tmp] = 1;
    ;
    if (it == s.begin()) break;
  }
  int sr = n, sc = m, num = 1;
  bool f = 0;
  while (sc >= 1 || sr >= 1) {
    while (us[num]) num++;
    if (sr >= 1 && sc >= 1) {
      if (!f) {
        for (int i = 1; i <= n; i++) {
          if (ans[i][sc]) break;
          while (us[num]) num++;
          ans[i][sc] = num;
          us[num] = 1;
        }
        f = 1;
        sc--;
      } else {
        for (int i = 1; i <= m; i++) {
          if (ans[sr][i]) break;
          while (us[num]) num++;
          ans[sr][i] = num;
          us[num] = 1;
        }
        f = 0;
        sr--;
      }
    } else if (sr >= 1) {
      for (int i = 1; i <= m; i++) {
        if (ans[sr][i]) break;
        while (us[num]) num++;
        ans[sr][i] = num;
        us[num] = 1;
      }
      sr--;
    } else {
      for (int i = 1; i <= n; i++) {
        if (ans[i][sc]) break;
        while (us[num]) num++;
        ans[i][sc] = num;
        us[num] = 1;
      }
      sc--;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", ans[i][j]);
    }
    printf("\n");
  }
  return 0;
}
