#include <bits/stdc++.h>
using namespace std;
int ans[1000 + 10][1000 + 10] = {};
int main() {
  int n, m, a1 = 0, a2 = 0, a3 = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int inp;
      cin >> inp;
      if (inp == 11) a1++;
      if (inp == 10 || inp == 1) a2++;
      if (!inp) a3++;
    }
  int l = 0;
  int x = 0, y = 0;
  while (l < a1) {
    ans[x][y] = 11;
    y++;
    if (y == m) {
      y = 0;
      x++;
    }
    l++;
  }
  l = 0;
  int r = 1;
  while (l < a2) {
    if (x && ans[x - 1][y] == 10)
      ans[x][y] = 1;
    else
      ans[x][y] = 10;
    y += r;
    if (y == m || y == -1) {
      r *= -1;
      y += r;
      x++;
    }
    l++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ans[i][j] < 10)
        cout << 0 << ans[i][j] << ' ';
      else
        cout << ans[i][j] << ' ';
    }
    cout << '\n';
  }
  return 0;
}
