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;
template <class T>
inline void rread(T &num) {
  num = 0;
  T f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') num = num * 10 + ch - '0', ch = getchar();
  num *= f;
}
inline int getgcd(int x, int y) {
  if (!x) return y;
  return getgcd(y % x, x);
}
inline int power(int x, int k, int p) {
  int res = 1;
  for (; k; k >>= 1, x = (long long)x * x % p)
    if (k & 1) res = (long long)res * x % p;
  return res;
}
const double pi = acos(-1);
inline void judge() { freopen("input.txt", "r", stdin); }
const int maxn = 8e3 + 5, maxm = 2e3 + 5;
int n, root, ndtot, flag, wrt;
int bel[maxn], vis[maxn], cnt[maxn][3], Q[maxn];
int hhy[maxn], a[maxm][maxm];
char s[maxn];
vector<int> son[maxn];
inline void dfs(int x) {
  memset(cnt[x], 0, sizeof(cnt[x]));
  if (x <= n) {
    bel[x] = vis[x];
    cnt[x][bel[x]]++;
    return;
  }
  int empty = 1, full = 1;
  for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++) {
    dfs(son[x][i]);
    if (bel[son[x][i]]) empty = 0;
    if (bel[son[x][i]] != 1) full = 0;
    cnt[x][bel[son[x][i]]]++;
  }
  if (empty)
    bel[x] = 0;
  else if (full)
    bel[x] = 1;
  else
    bel[x] = 2;
}
inline int Get(int x, vector<int> &E) {
  if (cnt[x][2] > 1) return 0;
  if (Q[x]) {
    if ((cnt[x][1] && bel[son[x][0]] != 1) ||
        (!cnt[x][1] && bel[son[x][0]] != 2))
      reverse(son[x].begin(), son[x].end());
    for (int(i) = (1); (i) <= (cnt[x][1]); (i)++) {
      if (bel[son[x][i - 1]] != 1) return 0;
      E.push_back(son[x][i - 1]);
    }
    if (cnt[x][2])
      if (bel[son[x][cnt[x][1]]] != 2 || !Get(son[x][cnt[x][1]], E)) return 0;
    for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++)
      if (bel[son[x][i]] == 0) E.push_back(son[x][i]);
  } else {
    if (cnt[x][1]) {
      int t1 = ++ndtot;
      for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++)
        if (bel[son[x][i]] == 1) son[t1].push_back(son[x][i]);
      if ((int((son[t1]).size())) == 1) t1 = son[t1][0];
      E.push_back(t1);
    }
    if (cnt[x][2])
      for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++)
        if (bel[son[x][i]] == 2 && !Get(son[x][i], E)) return 0;
    if (cnt[x][0]) {
      int t2 = ++ndtot;
      for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++)
        if (!bel[son[x][i]]) son[t2].push_back(son[x][i]);
      if ((int((son[t2]).size())) == 1) t2 = son[t2][0];
      E.push_back(t2);
    }
  }
  return 1;
}
inline int getr(int x, vector<int> &E) {
  int sz = (int((E).size()));
  if (!Get(x, E)) return 0;
  reverse(E.begin() + sz, E.end());
  return 1;
}
inline int getl(int x, vector<int> &E) { return Get(x, E); }
inline int check(int x) {
  if (x <= n) return 1;
  if (cnt[x][1] + cnt[x][2] == 1)
    for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++)
      if (bel[son[x][i]]) return check(son[x][i]);
  if (cnt[x][2] > 2) return 0;
  vector<int> tmp;
  if (Q[x]) {
    int St = 0, Ed = 0;
    for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++) {
      if (Ed && bel[son[x][i]]) return 0;
      if (St && !bel[son[x][i]]) Ed = 1;
      if (bel[son[x][i]] == 2) {
        if (!St) {
          if (!getr(son[x][i], tmp)) return 0;
        } else {
          if (!getl(son[x][i], tmp)) return 0;
        }
      } else
        tmp.push_back(son[x][i]);
      if (bel[son[x][i]]) St = 1;
    }
  } else {
    int t1 = ++ndtot;
    Q[t1] = 1;
    for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++)
      if (bel[son[x][i]] == 2) {
        if (!getr(son[x][i], son[t1])) return 0;
        break;
      }
    if (cnt[x][1]) {
      int t2 = ++ndtot;
      for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++)
        if (bel[son[x][i]] == 1) son[t2].push_back(son[x][i]);
      if (son[t2].size() == 1) t2 = son[t2][0];
      son[t1].push_back(t2);
    }
    int sec = 0;
    for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++)
      if (bel[son[x][i]] == 2) {
        if (!sec)
          sec = 1;
        else if (!getl(son[x][i], son[t1]))
          return 0;
      }
    if ((int((son[t1]).size())) == 1) t1 = son[t1][0];
    tmp.push_back(t1);
    for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++)
      if (!bel[son[x][i]]) tmp.push_back(son[x][i]);
  }
  son[x] = tmp;
  return 1;
}
inline void GR(int x) {
  if (x <= n) {
    hhy[++wrt] = x;
    return;
  }
  for (int(i) = (0); (i) < ((int((son[x]).size()))); (i)++) GR(son[x][i]);
}
int main() {
  rread(n);
  ndtot = n;
  root = ++ndtot;
  for (int(i) = (1); (i) <= (n); (i)++) son[root].push_back(i);
  for (int(i) = (1); (i) <= (n); (i)++) {
    scanf("%s", s + 1);
    for (int(j) = (1); (j) <= (n); (j)++) a[i][j] = vis[j] = s[j] - '0';
    dfs(root);
    if (!check(root)) {
      flag = 1;
      break;
    }
  }
  if (flag) return puts("NO"), 0;
  puts("YES");
  GR(root);
  for (int(i) = (1); (i) <= (n); (i)++) {
    for (int(j) = (1); (j) <= (n); (j)++) printf("%d", a[i][hhy[j]]);
    puts("");
  }
  return 0;
}