Problem: Let's consider an n × n square matrix, consisting of digits one and zero.

We'll consider a matrix good, if it meets the following condition: in each row of the matrix all ones go in one group. That is, each row of the matrix looks like that 00...0011...1100...00 (or simply consists of zeroes if it has no ones).

You are given matrix a of size n × n, consisting of zeroes and ones. Your task is to determine whether you can get a good matrix b from it by rearranging the columns or not.

Input

The first line contains integer n (1 ≤ n ≤ 500) — the size of matrix a.

Each of n following lines contains n characters "0" and "1" — matrix a. Note that the characters are written without separators.

Output

Print "YES" in the first line, if you can rearrange the matrix columns so as to get a good matrix b. In the next n lines print the good matrix b. If there are multiple answers, you are allowed to print any of them.

If it is impossible to get a good matrix, print "NO".

Examples

Input

6
100010
110110
011001
010010
000100
011001


Output

YES
011000
111100
000111
001100
100000
000111


Input

3
110
101
011


Output

NO

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int num = 0, k = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') k = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    num *= 10, num += ch - 48, ch = getchar();
  }
  return num * k;
}
struct PQTree {
  bool c, f;
  vector<int> a;
  int tp;
} t[1000000 + 5];
char ss[500 + 5][500 + 5];
int s[1000000 + 5], size[1000000 + 5], n, cnt = 0, tot = 0, ans[500 + 5];
void change(int p) {
  if (t[p].tp != 2 || t[p].f) return;
  t[p].c ^= 1;
  reverse(t[p].a.begin(), t[p].a.end());
}
void pushdown(int p) {
  if (!t[p].c) return;
  t[p].c = 0;
  for (int i = 0; i < t[p].a.size(); i++) change(t[p].a[i]);
}
void dfs(int p) {
  pushdown(p);
  size[p] = p <= n;
  for (int i = 0; i < t[p].a.size(); i++) {
    int v = t[p].a[i];
    dfs(v);
    s[p] += s[v], size[p] += size[v];
  }
}
void getAns(int p) {
  pushdown(p);
  if (p <= n) ans[++cnt] = p;
  for (int i = 0; i < t[p].a.size(); i++) getAns(t[p].a[i]);
}
void Dead() {
  puts("NO");
  exit(0);
}
void del(int p) { t[p].a.clear(), t[p].tp = t[p].c = t[p].f = 0; }
void modify(int p, int y) {
  pushdown(p);
  if (size[p] == s[p]) return;
  if (t[p].tp == 1) {
    vector<int> b, g, w;
    for (int i = 0; i < t[p].a.size(); i++) {
      int v = t[p].a[i];
      if (size[v] == s[v])
        b.push_back(v);
      else if (!s[v])
        w.push_back(v);
      else
        g.push_back(v);
    }
    if (g.size() > 2 || g.size() == 2 && y) Dead();
    int l = 0, r = 0;
    if (g.size() == 1) {
      if (!b.size() && !y)
        modify(g[0], 0);
      else {
        if (y)
          modify(g[0], y);
        else
          modify(g[0], 1);
      }
    }
    if (g.size() == 2) modify(g[0], 1), modify(g[1], 2);
    if (b.size())
      if (b.size() == 1)
        l = b[0];
      else
        t[l = ++tot].tp = 1, t[l].a = b;
    if (w.size())
      if (w.size() == 1)
        r = w[0];
      else
        t[r = ++tot].tp = 1, t[r].a = w;
    if (g.size() == 1) {
      if (!l)
        l = g[0];
      else {
        int v = ++tot;
        t[v].tp = 2, t[v].f = !y;
        if (y != 2) t[v].a.push_back(g[0]);
        t[v].a.push_back(l);
        if (y == 2) t[v].a.push_back(g[0]);
        l = v;
      }
    }
    if (g.size() == 2) {
      int v = ++tot;
      t[v].tp = 2, t[v].f = 1, t[v].a.push_back(g[0]);
      if (l) t[v].a.push_back(l);
      t[v].a.push_back(g[1]), l = v;
    }
    if (!y) {
      if (!r)
        t[p] = t[l];
      else {
        t[p].tp = 1, t[p].f = t[p].c = 0, t[p].a = w, t[p].a.push_back(l);
      }
    } else {
      t[p].tp = 2, t[p].f = t[p].c = 0, t[p].a.clear();
      if (y == 2 && l) t[p].a.push_back(l);
      if (r) t[p].a.push_back(r);
      if (y == 1) t[p].a.push_back(l);
    }
  } else {
    int l, r;
    for (l = 0; l < t[p].a.size(); l++)
      if (s[t[p].a[l]]) break;
    for (r = t[p].a.size() - 1; r >= 0; r--)
      if (s[t[p].a[r]]) break;
    for (int i = l + 1; i < r; i++)
      if (s[t[p].a[i]] != size[t[p].a[i]]) Dead();
    if (y == 1) {
      int v = t[p].a[r];
      if (r + 1 != t[p].a.size() || l < r && size[v] != s[v]) {
        if (!t[p].f) Dead();
        t[p].f = 0, change(p), modify(p, y);
        return;
      }
      t[p].f = 0;
    }
    if (y == 2) {
      int v = t[p].a[l];
      if (l || l < r && size[v] != s[v]) {
        if (!t[p].f) Dead();
        t[p].f = 0, change(p), modify(p, y);
        return;
      }
      t[p].f = 0;
    }
    if (l == r)
      modify(t[p].a[l], y);
    else
      modify(t[p].a[l], 1), modify(t[p].a[r], 2);
  }
}
int main() {
  scanf("%d", &n);
  t[tot = n + 1].tp = 1;
  for (int i = 1; i <= n; i++) t[tot].a.push_back(i);
  for (int i = 1; i <= n; i++) {
    scanf("%s", ss[i]);
    memset(s, 0, sizeof(s));
    for (int j = 1; j <= n; j++) s[j] = ss[i][j - 1] - 48;
    dfs(n + 1);
    if (!s[n + 1]) continue;
    modify(n + 1, 0);
  }
  getAns(n + 1);
  puts("YES");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) printf("%c", ss[i][ans[j] - 1]);
    puts("");
  }
  return 0;
}