#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 300;
long long A[MAXN][MAXN];
long long res[MAXN][MAXN];
bool mk[MAXN][MAXN];
long long ingree[MAXN][MAXN];
vector<pair<long long, long long>> L[MAXN][MAXN];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long N, M;
  cin >> N >> M;
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < M; j++) {
      cin >> A[i][j];
    }
  }
  set<long long> st1;
  set<long long> st2;
  for (long long i = 0; i < N; i++) {
    long long may = 0;
    for (long long j = 0; j < M; j++) {
      may = max(may, A[i][j]);
    }
    st1.insert(may);
  }
  for (long long j = 0; j < M; j++) {
    long long may = 0;
    for (long long i = 0; i < N; i++) {
      may = max(may, A[i][j]);
    }
    st2.insert(may);
  }
  long long px = -1, py = -1;
  set<pair<long long, pair<long long, long long>>> st;
  for (long long i = N * M; i >= 1; i--) {
    bool f1 = false, f2 = false;
    if (st1.find(i) != st1.end()) px++, f1 = true;
    if (st2.find(i) != st2.end()) py++, f2 = true;
    if (f2) {
      for (long long x = 0; x < N; x++) {
        if (x == px) continue;
        if (x < px) {
          ingree[x][py]++;
          L[x + 1][py].push_back({x, py});
        }
        if (x > px) {
          ingree[x][py]++;
          L[x - 1][py].push_back({x, py});
        }
      }
      for (long long x = 0; x < px; x++) {
        st.insert({ingree[x][py], {x, py}});
        mk[x][py] = true;
      }
    }
    if (f1) {
      for (long long y = 0; y < M; y++) {
        if (y == py) continue;
        if (y < py) {
          ingree[px][y]++;
          L[px][y + 1].push_back({px, y});
        }
        if (y > py) {
          ingree[px][y]++;
          L[px][y - 1].push_back({px, y});
        }
      }
      for (long long y = 0; y < py; y++) {
        st.insert({ingree[px][y], {px, y}});
        mk[px][y] = true;
      }
    }
    if (f1 || f2) {
      res[px][py] = i;
      mk[px][py] = true;
      for (auto v : L[px][py]) {
        if (mk[v.first][v.second]) {
          st.erase({ingree[v.first][v.second], {v.first, v.second}});
          ingree[v.first][v.second]--;
          st.insert({ingree[v.first][v.second], {v.first, v.second}});
        } else {
          ingree[v.first][v.second]--;
        }
      }
    } else {
      pair<long long, long long> pp = (*st.begin()).second;
      st.erase(st.begin());
      res[pp.first][pp.second] = i;
      for (auto v : L[pp.first][pp.second]) {
        if (mk[v.first][v.second]) {
          st.erase({ingree[v.first][v.second], {v.first, v.second}});
          ingree[v.first][v.second]--;
          st.insert({ingree[v.first][v.second], {v.first, v.second}});
        } else {
          ingree[v.first][v.second]--;
        }
      }
    }
  }
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < M; j++) {
      cout << res[i][j] << " ";
    }
    cout << '\n';
  }
  return 0;
}
