#include <bits/stdc++.h>
using namespace std;
const string ans[4] = {"11 ", "10 ", "01 ", "00 "};
int a[4], n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = (int)(0); i < (int)(n); ++i)
    for (int j = (int)(0); j < (int)(m); ++j) {
      int tmp;
      cin >> tmp;
      if (tmp == 11)
        ++a[0];
      else if (tmp == 0)
        ++a[3];
      else
        ++a[1];
    }
  vector<int> p;
  for (int i = (int)(0); i < (int)(n); ++i) {
    p.clear();
    for (int j = (int)(0); j < (int)(m); ++j) {
      if (a[0]-- > 0)
        p.push_back(0);
      else if (a[1]-- > 0)
        p.push_back(1 + (i % 2));
      else
        p.push_back(3);
    }
    if (i % 2)
      for (int i = (int)(0); i < (int)(p.size()); ++i) cout << ans[p[i]];
    else
      for (int i = (int)(0); i < (int)(p.size()); ++i)
        cout << ans[p[p.size() - i - 1]];
    cout << endl;
  }
  return 0;
}
