#include <bits/stdc++.h>
using namespace std;
char f[2000][4000];
int n, m, k[4000];
int main() {
  cin >> n >> m;
  int kol = 0, a[2][2];
  a[0][0] = 0;
  a[0][1] = 0;
  a[1][1] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      char c, d;
      cin >> c >> d;
      if (c == '0' && d == '0') {
        a[0][0]++;
      } else if (c == '1' && d == '0' || c == '0' && d == '1') {
        kol++;
        a[0][1]++;
      } else {
        kol += 2;
        a[1][1]++;
      }
    }
  int p = kol / (2 * m);
  if (kol % (2 * m) != 0) p++;
  for (int i = 1; i <= 2 * m; i++) k[i] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 2 * m; j++) {
      if (j % 2 == 0) {
        if (k[j] >= p) {
          if (f[i][j - 1] == '1') {
            f[i][j] = '0';
            a[0][1]--;
          } else {
            f[i][j] = '0';
            a[0][0]--;
          }
        } else {
          if (f[i][j - 1] == '1' && a[1][1]) {
            k[j]++;
            f[i][j] = '1';
            a[1][1]--;
          } else if (f[i][j - 1] == '0' && a[0][1]) {
            k[j]++;
            f[i][j] = '1';
            a[0][1]--;
          } else if (f[i][j - 1] == '1') {
            f[i][j] = '0';
            a[0][1]--;
          } else {
            f[i][j] = '0';
            a[0][0]--;
          }
        }
      } else {
        if (k[j] >= p)
          f[i][j] = '0';
        else {
          if (a[0][1] || a[1][1]) {
            k[j]++;
            f[i][j] = '1';
          } else {
            f[i][j] = '0';
          }
        }
      }
    }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 2 * m; j += 2) cout << f[i][j] << f[i][j + 1] << " ";
    cout << endl;
  }
  return 0;
}
