#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int N = 1e3 + 10;
int n, m, h[3], a[N << 1][N];
string s;
void fillin(int i, int j) {
  if (h[2])
    a[j][i] = a[j + 1][i] = 1, h[2]--;
  else if (h[1]) {
    int col = (a[j][i - 1]);
    a[j + col][i] = 1;
    h[1]--;
  }
}
int main() {
  cin >> n >> m;
  for (auto i = 1; i <= n; i++)
    for (auto j = 1; j <= m; j++) {
      cin >> s;
      h[count(s.begin(), s.end(), '1')]++;
    }
  for (auto i = 1; i <= n; i++)
    if (i & 1)
      for (int j = 1; j <= 2 * m; j += 2) fillin(i, j);
    else
      for (int j = 2 * m - 1; j >= 1; j -= 2) fillin(i, j);
  for (auto i = 1; i <= n; i++) {
    for (int j = 1; j <= 2 * m; j += 2) printf("%d%d ", a[j][i], a[j + 1][i]);
    printf("\n");
  }
}
