#include <bits/stdc++.h>
using namespace std;
int a, b, c, n, m, num, p, p1;
int ar[3100][3100];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n * m; i++) {
    cin >> num;
    if (num == 11)
      a++;
    else if (num == 0)
      c++;
    else
      b++;
  }
  p = a % m;
  p1 = a / m;
  for (int i = 0; i < a; i++) ar[i / m][i % m] = 11;
  for (int i = 0; i < b; i++) {
    for (int j = p; j < m; j++) {
      ar[p1][j] = 10;
      i++;
      if (i == b) break;
    }
    if (i == b) break;
    p1++;
    for (int j = p; j < m; j++) {
      ar[p1][j] = 1;
      i++;
      if (i == b) break;
    }
    if (i == b) break;
    for (int j = 0; j < p; j++) {
      ar[p1][j] = 10;
      i++;
      if (i == b) break;
    }
    if (i == b) break;
    for (int j = 0; j < p; j++) {
      ar[p1 + 1][j] = 1;
      i++;
      if (i == b) break;
    }
    if (i == b) break;
    i--;
    p1++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ar[i][j] < 10) cout << "0";
      cout << ar[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
