#include <bits/stdc++.h>
using namespace std;
long long a[3];
string as[1001][1001];
long long rc[2001];
int main() {
  long long n, m;
  cin >> n >> m;
  memset(a, 0, sizeof(a));
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) {
      string s;
      cin >> s;
      a[s[0] - '0' + s[1] - '0']++;
    }
  memset(rc, 0, sizeof(rc));
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) {
      if (a[2] > 0 && rc[j] < n) {
        as[rc[j]++][j] = "11";
        a[2]--;
      } else if (a[1] > 0 && rc[j] < n) {
        as[rc[j]++][j] = "10";
        a[1]--;
        if (a[1] > 0 && rc[j] < n) {
          as[rc[j]++][j] = "01";
          a[1]--;
        }
      } else if (a[0] > 0 && rc[j] < n) {
        as[rc[j]++][j] = "00";
        a[0]--;
      }
    }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) cout << as[i][j] << " ";
    cout << endl;
  }
  return 0;
}
