#include <bits/stdc++.h>
using namespace std;
int n, m, sz[2100], vl[2100][2100], fa[2100], f2[2100], sz1[2100], lb[2100],
    is[2100][2100], fu[2100], v1[2100], fr[2100], fg[2100][2100], v2[2100],
    as[2100], f3[2100];
char s[2100][2100], s2[2100][2100];
bitset<2100> f[2100];
int finds(int x) { return fa[x] == x ? x : fa[x] = finds(fa[x]); }
bool cmp(int a, int b) { return sz1[a] > sz1[b]; }
int check(int l, int r, int l1, int r1) {
  int as = min(r, r1) - max(l, l1) + 1;
  return as >= 0 ? as : 0;
}
void solve(vector<int> st) {
  int f1 = st[0], fg1 = 1;
  for (int i = 0; i < st.size(); i++) lb[st[i]] = -1, fr[st[i]] = -1;
  lb[f1] = 0;
  queue<int> sr;
  for (int i = 0; i < st.size(); i++)
    if (fg[f1][st[i]] && (st[i] != f1)) {
      lb[st[i]] = sz[f1] - vl[f1][st[i]];
      fr[st[i]] = f1;
      fr[f1] = st[i];
      sr.push(st[i]);
      sr.push(f1);
      break;
    }
  while (!sr.empty() && fg1) {
    int tp = sr.front();
    sr.pop();
    for (int i = 0; i < st.size(); i++)
      if (fg[tp][st[i]]) {
        int v1 = fr[tp], v2 = tp, v3 = st[i];
        int l1 = lb[v2] + sz[v2] - vl[v2][v3],
            l2 = lb[v2] + vl[v2][v3] - sz[v3];
        if (lb[v3] == -1) fr[v3] = v2, sr.push(v3);
        if (check(lb[v1], lb[v1] + sz[v1] - 1, l1, l1 + sz[v3] - 1) ==
            vl[v1][v3])
          fg1 &= lb[v3] == l1 || lb[v3] == -1, lb[v3] = l1;
        else if (check(lb[v1], lb[v1] + sz[v1] - 1, l2, l2 + sz[v3] - 1) ==
                 vl[v1][v3])
          fg1 &= lb[v3] == l2 || lb[v3] == -1, lb[v3] = l2;
        else
          fg1 = 0;
      }
  }
  int mn = 0;
  for (int i = 0; i < st.size(); i++) mn = min(mn, lb[st[i]]);
  for (int i = 0; i < st.size(); i++) lb[st[i]] = lb[st[i]] - mn;
  if (fg1) return;
  printf("NO\n");
  exit(0);
}
int main() {
  scanf("%d", &n);
  m = n;
  for (int i = 1; i <= n; i++) scanf("%s", s2[i] + 1), fa[i] = f2[i] = i;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (s2[i][j] == '1') sz1[i]++;
  sort(f2 + 1, f2 + n + 1, cmp);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) s[i][j] = s2[f2[i]][j], f3[f2[i]] = i;
  fu[0] = 1;
  for (int i = 1; i <= n; i++) fu[i] = 7ll * fu[i - 1] % 998244853;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (s[i][j] == '1')
        f[i].set(j, 1), sz[i]++, v1[j] = (v1[j] + fu[i]) % 998244853;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i <= j)
        vl[i][j] = (f[i] & f[j]).count();
      else
        vl[i][j] = vl[j][i];
      if (vl[i][j] && vl[i][j] < sz[i] && vl[i][j] < sz[j])
        fa[finds(j)] = finds(i), fg[i][j] = 1;
      if (vl[i][j] == sz[j] && (sz[i] > sz[j] || i < j)) is[j][i] = 1;
    }
  for (int i = 1; i <= n; i++)
    if (!lb[i]) {
      vector<int> fu1;
      for (int j = 1; j <= n; j++)
        if (finds(j) == finds(i)) fu1.push_back(j);
      solve(fu1);
      int as = 0, fu3 = 0;
      for (int j = 1; j <= n; j++) {
        int fg = 1;
        for (int k = 0; k < fu1.size(); k++) fg &= is[fu1[k]][j];
        fu3 = (fu3 + fg * fu[j]) % 998244853;
      }
      for (int j = 1; j <= n; j++)
        if (v2[j] == fu3) {
          as = j;
          break;
        }
      for (int k = 0; k < fu1.size(); k++) lb[fu1[k]] += as;
      for (int k = 0; k < fu1.size(); k++)
        for (int j = lb[fu1[k]]; j < lb[fu1[k]] + sz[fu1[k]]; j++)
          v2[j] = (v2[j] + fu[fu1[k]]) % 998244853;
    }
  for (int i = 1; i <= m; i++)
    for (int j = 1; j <= m; j++)
      if (v2[i] == v1[j]) {
        as[i] = j, v1[j] = -1;
        break;
      }
  printf("YES\n");
  for (int i = 1; i <= n; i++, printf("\n"))
    for (int j = 1; j <= m; j++) printf("%c", s[f3[i]][as[j]]);
}
