#include <bits/stdc++.h>
using namespace std;
char ans[1010][1010][3];
int main() {
  int n, m;
  int c[3] = {0, 0, 0};
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char str[3];
      cin >> str;
      int d = str[0] + str[1] - 96;
      c[d]++;
    }
  int p = 0;
  while (c[2]--) {
    int r = p / m, c = p % m;
    if (r % 2) c = m - 1 - c;
    strcpy(ans[r][c], "11");
    p++;
  }
  while (c[1]--) {
    int r = p / m, c = p % m;
    if (r % 2) c = m - 1 - c;
    if (r % 2)
      strcpy(ans[r][c], "10");
    else
      strcpy(ans[r][c], "01");
    p++;
  }
  while (c[0]--) {
    int r = p / m, c = p % m;
    if (r % 2) c = m - 1 - c;
    strcpy(ans[r][c], "00");
    p++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (j) putchar(' ');
      printf("%s", ans[i][j]);
    }
    puts("");
  }
  return 0;
}
