#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
int key[600 * 3], root, tot, n, size[600 * 3], s[600 * 3], sign[600 * 3],
    p[600 * 3];
char c[600], a[600][600];
vector<int> E[600 * 3];
void build() {
  root = tot = n + 1;
  for (int i = 1; i <= n; ++i) E[tot].push_back(i);
}
void dfs(int x) {
  if (x <= n) {
    size[x] = 1;
    s[x] = c[x] == '1';
    return;
  }
  size[x] = s[x] = 0;
  for (int y : E[x]) dfs(y), size[x] += size[y], s[x] += s[y];
}
void fail(string result) {
  cout << "NO" << endl;
  exit(0);
}
void updata(int x) {
  if (sign[x]) {
    reverse(E[x].begin(), E[x].end());
    for (int y : E[x]) sign[y] ^= 1;
    sign[x] = 0;
  }
}
void modify(int x) {
  if (key[x] != 2) fail("1");
  key[x] = 1;
  sign[x] = 1;
  updata(x);
}
int solve(int x, int type) {
  updata(x);
  if (x <= n) return x;
  if (key[x] == 0) {
    vector<int> all, empty, w, tmp;
    for (int y : E[x]) {
      if (size[y] == s[y])
        all.push_back(y);
      else if (s[y] == 0)
        empty.push_back(y);
      else
        w.push_back(y);
    }
    if (w.size() > 2) fail("2");
    if (!(type == 0 || w.size() < 2)) fail("3");
    if (all.size() == 0 && w.size() == 1 && type == 0) {
      for (int &y : E[x])
        if (y == w[0]) {
          y = solve(w[0], 0);
          return x;
        }
    }
    int mid;
    if (all.size() == 0)
      mid = 0;
    else if (all.size() == 1)
      mid = all[0];
    else {
      mid = ++tot;
      key[mid] = 0;
      E[mid] = all;
    }
    int p;
    if (type != 1 && w.size()) tmp.push_back(solve(w[0], 2));
    if (mid) tmp.push_back(mid);
    if (type != 2 && w.size() >= (type == 0 ? 2 : 1))
      tmp.push_back(solve(w[w.size() - 1], 1));
    assert(tmp.size() > 0);
    if (tmp.size() == 1)
      p = tmp[0];
    else {
      p = ++tot;
      key[p] = 2;
      E[p] = tmp;
    }
    int q;
    if (empty.size() == 0)
      q = p;
    else {
      q = ++tot;
      if (type == 0) {
        key[q] = 0;
        E[q] = empty;
        E[q].push_back(p);
      } else {
        int np;
        if (empty.size() == 1)
          np = empty[0];
        else {
          np = ++tot;
          key[np] = 0;
          E[np] = empty;
        }
        key[q] = 1;
        if (type == 1)
          E[q].push_back(p), E[q].push_back(np);
        else
          E[q].push_back(np), E[q].push_back(p);
      }
    }
    return q;
  } else {
    int l = E[x][0], r = E[x][E[x].size() - 1];
    if (type == 1 && !(size[l] == s[l] || (s[l] != 0 && size[r] != s[r])))
      modify(x);
    else if (type == 2 && !(size[r] == s[r] || (s[r] != 0 && size[l] != s[l])))
      modify(x);
    int last = -1, flag = 0, cnt = 0, total = 0;
    for (int y : E[x]) {
      int w;
      if (size[y] == s[y])
        w = 2;
      else if (s[y] == 0)
        w = 0;
      else
        w = 1;
      if (last != -1) {
        if (w > last && type == 1) fail("4");
        if (w < last && type == 2) fail("5");
        if (!w && last) flag = 1;
        if (flag && w && !last) fail("6");
      }
      last = w;
      if (w == 1) cnt++;
      total += (w > 0);
    }
    if (cnt > (type == 0 ? 2 : 1)) fail("7");
    cnt = 0;
    for (int &y : E[x]) {
      int tmp = s[y];
      if (tmp > 0 && tmp < size[y]) {
        if (type == 1)
          y = solve(y, 1);
        else if (type == 2)
          y = solve(y, 2);
        else if (total == 1)
          y = solve(y, 0);
        else {
          if (!cnt)
            y = solve(y, 2);
          else
            y = solve(y, 1);
        }
      }
      cnt += (tmp > 0);
    }
    return x;
  }
}
void getans(int x) {
  updata(x);
  if (x <= n) p[++p[0]] = x;
  for (int y : E[x]) getans(y);
}
int main() {
  scanf("%d", &n);
  build();
  for (int i = 1; i <= n; ++i) {
    scanf("%s", c + 1);
    for (int j = 1; j <= n; ++j) a[i][j] = c[j];
    dfs(root);
    if (s[root] == 0) continue;
    root = solve(root, 0);
  }
  getans(root);
  puts("YES");
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) printf("%c", a[i][p[j]]);
    puts("");
  }
}
