#include <bits/stdc++.h>
using namespace std;
string tostring(long long n) {
  ostringstream ss;
  ss << n;
  return ss.str();
}
long long tonumber(string str) {
  stringstream ss;
  ss << str;
  long long n;
  ss >> n;
  return n;
}
int main() {
  int n, m, s11 = 0, s10 = 0, s0 = 0;
  scanf("%d %d", &n, &m);
  string arr;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr;
      if (arr == "11")
        s11++;
      else if (arr == "00")
        s0++;
      else
        s10++;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s11)
        printf("11 "), s11--;
      else if (s10 && m - j <= s10) {
        if (i % 2)
          printf("10 "), s10--;
        else
          printf("01 "), s10--;
      } else if (s0)
        printf("00 "), s0--;
    }
    printf("\n");
  }
}
