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;
const int mod = 1e9 + 7;
long long qpow(long long x, long long k) {
  return k == 0 ? 1
                : 1ll * qpow(1ll * x * x % mod, k >> 1) * (k & 1 ? x : 1) % mod;
}
const int maxn = 511;
const int maxm = 511;
const int maxv = maxn + maxm * 3;
struct PQtree {
  int n, tot, ty[maxv];
  int sz[maxv], szr[maxv];
  int fail;
  char *s;
  vector<int> con[maxv];
  void init(int _n) {
    n = _n;
    memset(ty, 0, sizeof(ty));
    tot = n + 1;
    for (int i = 1; i <= n; i++) con[n + 1].push_back(i);
  }
  void dfs(int x) {
    sz[x] = szr[x] = 0;
    if (x <= n) {
      sz[x] = 1;
      szr[x] = s[x] == '1';
    }
    for (auto u : con[x]) {
      dfs(u);
      sz[x] += sz[u];
      szr[x] += szr[u];
    }
  }
  int mergeP(vector<int> v) {
    if (!v.size()) return 0;
    if (v.size() == 1) return v[0];
    int p = ++tot;
    for (auto x : v) con[p].push_back(x);
    return p;
  }
  void addson(int x, int u) {
    if (u) con[x].push_back(u);
  }
  int join(int x, int y) {
    for (auto u : con[y]) con[x].push_back(u);
    return x;
  }
  int solve(int x, int t) {
    if (fail) return 0;
    vector<int> v[3];
    for (auto u : con[x])
      v[(szr[u] == 0 ? 0 : (szr[u] < sz[u] ? 1 : 2))].push_back(u);
    if (v[1].size() > 2 || t > 0 && v[1].size() > 1) {
      fail = 1;
      return 0;
    }
    if (t == 0 && v[1].size() == 1 && v[2].size() == 0)
      return solve(v[1][0], 0);
    if (ty[x] == 0) {
      int p2 = mergeP(v[2]);
      if (t == 0) {
        con[x] = v[0];
        if (v[1].size() == 0)
          addson(x, p2);
        else if (v[1].size() == 1) {
          int p1 = solve(v[1][0], 1);
          addson(p1, p2);
          addson(x, p1);
        } else {
          int p1 = solve(v[1][0], 1);
          addson(p1, p2);
          p1 = join(p1, solve(v[1][1], 2));
          addson(x, p1);
        }
        return x;
      } else {
        ty[x] = 1;
        con[x].clear();
        addson(x, mergeP(v[0]));
        if (v[1].size() > 0) join(x, solve(v[1][0], 1));
        addson(x, p2);
        if (t == 2) reverse(con[x].begin(), con[x].end());
        return x;
      }
    } else {
      if ((szr[con[x][0]] == 0
               ? 0
               : (szr[con[x][0]] < sz[con[x][0]] ? 1 : 2)) == 2 ||
          (szr[con[x].back()] == 0
               ? 0
               : (szr[con[x].back()] < sz[con[x].back()] ? 1 : 2)) == 0)
        reverse(con[x].begin(), con[x].end());
      vector<int> ncon;
      int tmp = 0;
      for (auto u : con[x]) {
        int st = (szr[u] == 0 ? 0 : (szr[u] < sz[u] ? 1 : 2));
        if (st == 1) {
          int p1;
          if (tmp == 0)
            tmp = 1, p1 = solve(u, 1);
          else if (tmp == 1 && t == 0)
            tmp = 2, p1 = solve(u, 2);
          else {
            fail = 2;
            return 0;
          }
          for (auto v : con[p1]) ncon.push_back(v);
        } else if (st == 2) {
          ncon.push_back(u);
          if (tmp == 0)
            tmp++;
          else if (tmp == 2) {
            fail = 3;
            return 0;
          }
        } else if (st == 0) {
          ncon.push_back(u);
          if (tmp == 1) tmp++;
        }
      }
      if (t > 0 && tmp == 2) {
        fail = 4;
        return 0;
      }
      con[x] = ncon;
      if (t == 2) reverse(con[x].begin(), con[x].end());
      return x;
    }
  }
  void restrict(char *_s) {
    s = _s;
    dfs(n + 1);
    solve(n + 1, 0);
  }
  vector<int> ans;
  void putans(int x) {
    if (x <= n) ans.push_back(x);
    for (auto u : con[x]) putans(u);
  }
  vector<int> getans() {
    ans.clear();
    putans(n + 1);
    return ans;
  }
  void debug(int x) {
    if (x <= n) return;
    if (0)
      cout << "node id = " << x << " type = " << (ty[x] == 0 ? 'P' : 'Q')
           << endl;
    if (0) cout << "son[x] = ";
    for (auto u : con[x])
      if (0) cout << u << " ";
    if (0) cout << endl;
    for (auto u : con[x]) debug(u);
  }
} A;
char s[maxn][maxn];
int main() {
  int n;
  scanf("%d", &n);
  A.init(n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
    A.restrict(s[i]);
  }
  if (A.fail)
    puts("NO");
  else {
    puts("YES");
    vector<int> v = A.getans();
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) putchar(s[i][v[j - 1]]);
      puts("");
    }
  }
  return 0;
}