#include <bits/stdc++.h>
using namespace std;
struct pp {
  int bia, p[5];
  bool ki;
  vector<int> b;
} a[10010];
int n, root, nu, na, an[1010];
char c[1010][1010];
bool getl(int x, vector<int> &p) {
  if (x <= n) return 0;
  if (a[x].p[3] > 1) return 1;
  if (a[x].ki) {
    vector<int>::iterator l = a[x].b.begin();
    if ((a[x].p[1] && a[*l].bia != 1) ||
        (!a[x].p[1] && a[x].p[3] && a[*l].bia != 3))
      reverse(a[x].b.begin(), a[x].b.end());
    l = a[x].b.begin();
    for (int i = a[x].p[1]; i; i--, l++) {
      if (a[*l].bia != 1) return 1;
      p.push_back(*l);
    }
    if (a[x].p[3])
      if (a[*l].bia != 3)
        return 1;
      else {
        getl(*l, p);
        l++;
      }
    for (; l != a[x].b.end(); l++) {
      p.push_back(*l);
    }
  } else {
    if (a[x].p[1]) {
      int q = ++nu;
      a[q].ki = 0;
      for (vector<int>::iterator i = a[x].b.begin(); i != a[x].b.end(); i++)
        if (a[*i].bia == 1) a[q].b.push_back(*i);
      if (a[q].b.size() == 1) q = a[q].b[0];
      p.push_back(q);
    }
    for (vector<int>::iterator i = a[x].b.begin(); i != a[x].b.end(); i++)
      if (a[*i].bia == 3)
        if (getl(*i, p)) return 1;
    if (a[x].p[2]) {
      int q = ++nu;
      a[q].ki = 0;
      for (vector<int>::iterator i = a[x].b.begin(); i != a[x].b.end(); i++)
        if (a[*i].bia == 2) a[q].b.push_back(*i);
      if (a[q].b.size() == 1) q = a[q].b[0];
      p.push_back(q);
    }
  }
  return 0;
}
bool getr(int x, vector<int> &p) {
  int s = p.size();
  if (getl(x, p)) return 1;
  reverse(p.begin() + s, p.end());
  return 0;
}
bool wor(int x) {
  if (x <= n) return 0;
  if (a[x].p[3] > 2) return 1;
  if (a[x].p[3] == 0 && a[x].p[1] == 0) return 0;
  if (a[x].p[3] + a[x].p[1] == 1)
    for (vector<int>::iterator i = a[x].b.begin(); i != a[x].b.end(); i++)
      if (a[*i].bia != 2) return wor(*i);
  if (!a[x].ki) {
    vector<int> b;
    int p = ++nu, q;
    a[p].ki = true;
    if (a[x].p[3]) {
      for (vector<int>::iterator i = a[x].b.begin(); i != a[x].b.end(); i++)
        if (a[*i].bia == 3) {
          if (getr(*i, a[p].b)) return 1;
          break;
        }
    }
    if (a[x].p[1]) {
      q = ++nu;
      a[q].ki = false;
      for (vector<int>::iterator i = a[x].b.begin(); i != a[x].b.end(); i++)
        if (a[*i].bia == 1) a[q].b.push_back(*i);
      if (a[q].b.size() == 1) q = a[q].b[0];
      a[p].b.push_back(q);
    }
    int j = 0;
    for (vector<int>::iterator i = a[x].b.begin(); i != a[x].b.end(); i++)
      if (a[*i].bia == 3) {
        if (j) {
          if (getl(*i, a[p].b)) return 1;
        } else
          j = 1;
      }
    if (a[p].b.size() == 1) p = a[p].b[0];
    b.push_back(p);
    for (vector<int>::iterator i = a[x].b.begin(); i != a[x].b.end(); i++)
      if (a[*i].bia == 2) b.push_back(*i);
    a[x].b = b;
  } else {
    vector<int> b;
    bool s1 = 1, s2 = 1;
    for (vector<int>::iterator i = a[x].b.begin(); i != a[x].b.end(); i++) {
      if (s1 && s2) {
        if (a[*i].bia == 3) {
          s1 = 0;
          getr(*i, b);
        } else {
          b.push_back(*i);
          if (a[*i].bia == 1) s1 = 0;
        }
      } else {
        if (s2) {
          if (a[*i].bia == 2) {
            s2 = 0;
            b.push_back(*i);
          }
          if (a[*i].bia == 1) {
            b.push_back(*i);
          }
          if (a[*i].bia == 3) {
            s2 = 0;
            getl(*i, b);
          }
        } else {
          if (a[*i].bia != 2) return 1;
          b.push_back(*i);
        }
      }
    }
    a[x].b = b;
  }
  return 0;
}
void dfs(int p, int x) {
  a[x].bia = 0;
  a[x].p[1] = 0;
  a[x].p[2] = 0;
  a[x].p[3] = 0;
  if (x <= n) {
    if (c[p][x] == '1')
      a[x].bia = 1;
    else
      a[x].bia = 2;
    return;
  }
  bool t1 = true, t2 = true;
  for (vector<int>::iterator i = a[x].b.begin(); i != a[x].b.end(); i++) {
    dfs(p, *i);
    if (a[*i].bia != 1) t1 = false;
    if (a[*i].bia != 2) t2 = false;
    a[x].p[a[*i].bia]++;
  }
  if (t1) {
    a[x].bia = 1;
  } else {
    if (t2)
      a[x].bia = 2;
    else
      a[x].bia = 3;
  }
}
void ge(int x) {
  if (x <= n) {
    an[++na] = x;
    return;
  }
  for (vector<int>::iterator i = a[x].b.begin(); i != a[x].b.end(); i++) ge(*i);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", c[i] + 1);
  nu = n + 1;
  for (int i = 1; i <= n; i++) a[n + 1].b.push_back(i);
  for (int i = 1; i <= n; i++) {
    dfs(i, n + 1);
    if (wor(n + 1)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  ge(n + 1);
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) cout << c[i][an[j]];
    cout << endl;
  }
  return 0;
}
