#include <bits/stdc++.h>
using namespace std;
vector<string> res;
int main() {
  string s;
  int n, m, len, one = 0, two = 0, three = 0;
  cin >> n >> m;
  len = m * n;
  if (len == 1) {
    cin >> s;
    cout << s;
    return 0;
  }
  for (int i = 0; i < len; i++) {
    cin >> s;
    if (s == "00")
      ++one;
    else if (s == "10" || s == "01")
      ++two;
    else
      ++three;
  }
  for (int i = 0; i < three; i++) {
    cout << "11"
         << " ";
    if ((i + 1) % m == 0) cout << endl;
  }
  bool f = 0;
  for (int i = 0; i < two; i++) {
    if (i < m - three % m)
      res.push_back("10");
    else {
      if ((i + three % m) % m == 0) f = !f;
      if (f)
        res.push_back("01");
      else
        res.push_back("10");
    }
  }
  for (int j = 0; j < one; j++) res.push_back("00");
  if (one || two) {
    unsigned int i = 0;
    for (i = 0; i < m - (three % m); i++) cout << res[i] << " ";
    cout << endl;
    while (i < res.size()) {
      vector<string> temp;
      for (int j = i; j < i + m; j++) temp.push_back(res[j]);
      reverse(temp.begin(), temp.end());
      for (int j = 0; j < m; j++) cout << temp[j] << " ";
      cout << endl;
      i += m;
    }
  }
  return 0;
}
