#include <bits/stdc++.h>
using namespace std;
const int N = 250;
int n, m, arr[N + 5][N + 5], line[N + 5], row[N + 5];
int judge[N * N + 5], ans[N + 5][N + 5], x, y;
int L[N + 5], R[N + 5];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      scanf("%d", &arr[i][j]), line[i] = max(line[i], arr[i][j]),
                               row[j] = max(row[j], arr[i][j]);
  for (int i = 1; i <= n; i++) judge[line[i]] = 1;
  for (int i = 1; i <= m; i++) judge[row[i]] = judge[row[i]] ? 3 : 2;
  for (int k = n * m; k >= 1; k--)
    if (judge[k] == 3)
      ans[++x][++y] = k, L[x] = R[x] = y;
    else if (judge[k] == 2)
      ans[x][++y] = k, R[x] = y;
    else if (judge[k] == 1)
      ans[++x][y] = k, L[x] = R[x] = y;
    else {
      for (int i = 1; i <= x; i++) {
        int j = L[i] - 1;
        if (j && !ans[i][j] && ans[i - 1][j] || ans[i + 1][j]) {
          ans[i][j] = k, L[i] = j;
          break;
        }
        j = R[i] + 1;
        if (j <= m && !ans[i][j] && ans[i - 1][j] || ans[i + 1][j]) {
          ans[i][j] = k;
          R[i] = j;
          break;
        }
      }
    }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%d ", ans[i][j]);
    puts("");
  }
  return 0;
}
