#include <bits/stdc++.h>
using namespace std;
int cnt11 = 0, cnt10 = 0, cnt00 = 0;
int n, m;
int main() {
  cin >> n >> m;
  string s;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> s;
      if (s == "00")
        cnt00++;
      else if (s == "11")
        cnt11++;
      else
        cnt10++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (cnt11) {
        cout << "11 ";
        cnt11--;
      } else {
        if (cnt10 && (m - j) <= cnt10) {
          cnt10--;
          cout << ((i & 1) ? "01 " : "10 ");
        } else {
          cout << "00 ";
          cnt00--;
        }
      }
    }
    cout << '\n';
  }
}
