#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int a[3] = {};
  cin >> n >> m;
  int b[n + 1][m + 1];
  for (int i = 0; i < n * m; i++) {
    string s;
    cin >> s;
    if (s == "01" || s == "10")
      a[1]++;
    else if (s == "11")
      a[0]++;
    else
      a[2]++;
  }
  for (int i = 0; i < n; i++) {
    if (i % 2 == 0)
      for (int j = 0; j < m; j++) {
        if (a[0] > 0) {
          b[i][j] = 2;
          a[0]--;
        } else if (a[1] > 0) {
          if (i > 0 && b[i - 1][j] == 1)
            b[i][j] = -1;
          else
            b[i][j] = 1;
          a[1]--;
        } else {
          b[i][j] = 0;
        }
      }
    else {
      for (int j = m - 1; j >= 0; j--) {
        if (a[0] > 0) {
          b[i][j] = 2;
          a[0]--;
        } else if (a[1] > 0) {
          if (i > 0 && b[i - 1][j] == 1)
            b[i][j] = -1;
          else
            b[i][j] = 1;
          a[1]--;
        } else {
          b[i][j] = 0;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (b[i][j] == 2)
        cout << "11";
      else if (b[i][j] == 1)
        cout << "10";
      else if (b[i][j] == -1)
        cout << "01";
      else if (b[i][j] == 0)
        cout << "00";
      if (j != m - 1) cout << " ";
    }
    cout << endl;
  }
}
