#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
signed main() {
  long long n, m;
  cin >> n >> m;
  string ans[n][m];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      ans[i][j] = "00";
    }
  }
  long long cnt11 = 0, cnt01 = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      string inp;
      cin >> inp;
      if (inp == "11")
        cnt11++;
      else if (inp == "01" || inp == "10")
        cnt01++;
    }
  }
  long long saveN = 0, saveM = 0;
  while (cnt11 > 0) {
    ans[saveN][saveM] = "11";
    cnt11--;
    saveM = (saveM + 1) % m;
    if (!saveM) saveN++;
  }
  while (cnt01 > 0) {
    if (ans[saveN][saveM] == "00") {
      ans[saveN][saveM] = "01";
      cnt01--;
      if (saveN + 1 < n && cnt01 > 0) {
        if (ans[saveN + 1][saveM] == "00") {
          ans[saveN + 1][saveM] = "10";
          cnt01--;
        }
      }
    }
    saveM = (saveM + 1) % m;
    if (!saveM) saveN++;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cout << ans[i][j] << " \n"[j == m - 1];
    }
  }
  return 0;
}
