#include <bits/stdc++.h>
using namespace std;
const int maxN = 1000 + 321;
int a[maxN][maxN];
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  int r[3] = {};
  int count = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int d;
      cin >> d;
      if (d == 1 || d == 10) {
        r[1]++;
        count++;
        continue;
      }
      if (d == 11) {
        r[2]++;
        count += 2;
        continue;
      }
      r[0]++;
    }
  }
  for (int i = 0; i < m; i++) {
    int u1 = count / (2 * (m - i));
    if (count % (2 * (m - i))) u1++;
    count -= u1;
    int u2 = count / (2 * (m - i) - 1);
    if (count % (2 * (m - i) - 1)) u2++;
    count -= u2;
    int up = r[2] / (m - i);
    if (r[2] % (m - i)) up++;
    r[2] -= up;
    u1 -= up;
    u2 -= up;
    if (u2 + u1 + up > n) {
      int t = n - up - u1 - u2;
      t *= -1;
      u1 -= t / 2 + t % 2;
      u2 -= t / 2;
      count += t;
    }
    if (u1 < u2) swap(u1, u2);
    for (int j = 0; j < n; j++) {
      if (up) {
        a[j][i] = 11;
        up--;
        continue;
      }
      if (u1) {
        a[j][i] = 10;
        u1--;
        if (u2) {
          a[j + 1][i] = 1;
          j++;
          u2--;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 11) cout << "11 ";
      if (a[i][j] == 1) cout << "01 ";
      if (a[i][j] == 10) cout << "10 ";
      if (a[i][j] == 0) cout << "00 ";
    }
    cout << endl;
  }
  return 0;
}
