#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j, t, ii, rr, n, l, r, m, k, ans;
  cin >> n >> m;
  int a[n][m];
  int aa[4] = {0};
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> k;
      if (k == 0)
        aa[0]++;
      else if (k == 11)
        aa[3]++;
      else
        aa[1]++;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (aa[3] != 0) {
        a[i][j] = 3;
        aa[3]--;
        if (aa[3] == 0 && j != m - 1) {
          l = j + 1;
          j++;
          while (j < m) {
            if (aa[1] != 0) {
              a[i][j] = i % 2 + 1;
              aa[1]--;
            } else {
              a[i][j] = 0;
              aa[0]--;
            }
            j++;
          }
          if (aa[1] != 0) {
            i++;
            if (i >= n) break;
            j = l;
            while (j < m) {
              if (aa[1] != 0) {
                a[i][j] = i % 2 + 1;
                aa[1]--;
              } else {
                a[i][j] = 0;
                aa[0]--;
              }
              j++;
            }
            j = l - 1;
            while (j >= 0) {
              if (aa[0] != 0) {
                a[i][j] = 0;
                aa[0]--;
              } else {
                a[i][j] = i % 2 + 1;
                aa[1]--;
              }
              j--;
            }
          }
          break;
        }
      } else {
        if (aa[1] != 0) {
          a[i][j] = i % 2 + 1;
          aa[1]--;
        } else
          a[i][j] = 0;
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (a[i][j] == 3)
        cout << "11 ";
      else if (a[i][j] == 2)
        cout << "10 ";
      else if (a[i][j] == 1)
        cout << "01 ";
      else
        cout << "00 ";
    }
    cout << endl;
  }
}
