#include <bits/stdc++.h>
using namespace std;
int main() {
  ios ::sync_with_stdio();
  int n, m;
  cin >> n >> m;
  string abs[n + 100][m + 100];
  int a[n + 100][2 * m + 100];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> abs[i][j];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (abs[i][j][0] == '1')
        a[i][2 * j] = 1;
      else
        a[i][2 * j] = 0;
      if (abs[i][j][1] == '1')
        a[i][2 * j + 1] = 1;
      else
        a[i][2 * j + 1] = 0;
    }
  }
  int b[n + 100][2 * m + 100];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 2 * m; j++) b[i][j] = -1;
  int s = 0;
  int ss = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j * 2] == 1 && a[i][j * 2 + 1] == 1) s++;
      if (a[i][j * 2] == 1 && a[i][j * 2 + 1] == 0) ss++;
      if (a[i][j * 2] == 0 && a[i][j * 2 + 1] == 1) ss++;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (s > 0) {
      for (int j = 1; j <= m; j++) {
        if (s > 0 && b[i][j * 2] == -1) {
          b[i][j * 2] = 1;
          b[i][j * 2 + 1] = 1;
          s--;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (ss > 0) {
      for (int j = 1; j <= m; j++) {
        if (ss > 0 && b[i][j * 2] == -1) {
          if (i == n || ss == 1) {
            b[i][2 * j] = 1;
            b[i][2 * j + 1] = 0;
            ss--;
          } else {
            b[i][2 * j] = 1;
            b[i][2 * j + 1] = 0;
            b[i + 1][2 * j] = 0;
            b[i + 1][2 * j + 1] = 1;
            ss = ss - 2;
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (b[i][j * 2] == -1) {
        b[i][j * 2] = 0;
        b[i][j * 2 + 1] = 0;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << b[i][j * 2] << b[i][j * 2 + 1] << " ";
    }
    cout << endl;
  }
}
