#include <bits/stdc++.h>
using namespace std;
int arr[4];
string bo[4] = {"11", "10", "01", "00"};
int res[1000 + 10][1000 + 10];
int main() {
  int n, m, k, d, tem1 = 0, tem2 = 0, tem3, tem4;
  string s, c;
  cin >> n >> m;
  getline(cin, s);
  for (int i = 0; i < n; i++) {
    getline(cin, s);
    for (int j = 0; j < s.length(); j += 3) {
      if (s[j] == '1' && s[j + 1] == '1') {
        arr[0]++;
        tem1++;
      } else if (s[j] == '1' && s[j + 1] == '0') {
        arr[1]++;
      } else if (s[j] == '0' && s[j + 1] == '1') {
        arr[1]++;
      } else {
        arr[3]++;
      }
    }
  }
  bool vis = false;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (arr[0] != 0) {
        arr[0]--;
        res[i][j] = 0;
      } else {
        if (arr[1] >= m + 1 - j) {
          if (i % 2 == 0)
            res[i][j] = 1;
          else
            res[i][j] = 2;
          arr[1]--;
        } else {
          res[i][j] = 3;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cout << bo[res[i][j]] << " ";
    }
    cout << "\n";
  }
  return 0;
}
