#include <bits/stdc++.h>
int fin[1005][1005];
int main() {
  int num[5], n, m, ans;
  scanf("%d%d", &n, &m);
  memset(num, 0, sizeof(num));
  for (int i = 1; i <= n * m; i++) {
    int ans;
    scanf("%d", &ans);
    if (ans == 1 || ans == 10) num[1]++;
    if (ans == 11) num[2]++;
  }
  int r, c = num[2] % m;
  if (num[2] % m)
    r = num[2] / m + 1;
  else
    r = num[2] / m;
  for (int i = 1; i <= r; i++) {
    for (int j = 1; j <= m; j++) {
      if (num[2]) {
        printf("11");
        num[2]--;
      } else {
        printf("01");
        num[1]--;
      }
      if (j != m) printf(" ");
    }
    printf("\n");
  }
  int r1 = r + 1;
  c = m;
  int temp = 0;
  while (num[1]) {
    if (!temp)
      fin[r1][c] = 10;
    else
      fin[r1][c] = 1;
    c--;
    num[1]--;
    if (!c) {
      c = m;
      r1++;
      if (temp)
        temp = 0;
      else
        temp = 1;
    }
  }
  while (r1 < n) {
    fin[r1][c] = 0;
    c--;
    if (!c) {
      c = m;
      r1++;
    }
  }
  r++;
  for (r; r <= n; r++) {
    printf("%02d", fin[r][1]);
    for (int j = 2; j <= m; j++) printf(" %02d", fin[r][j]);
    printf("\n");
  }
  return 0;
}
