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;
void EXIT(string s) {
  printf("%s\n", s.c_str());
  exit(0);
}
const int maxn = 505;
const int INF = 0x3f3f3f3f;
int n, pos;
int ans[maxn];
char s[maxn][maxn];
namespace PQ {
const int maxv = 1000005;
int rt, tot;
class Node {
 public:
  int tp;
  bool full, empty;
  vector<int> child;
} t[maxv];
int newnode(int _tp) {
  tot++;
  t[tot].tp = _tp;
  t[tot].full = t[tot].empty = true;
  t[tot].child.clear();
  return tot;
}
bool leaf(int x) { return x >= 2 && x <= n + 1; }
void init() {
  rt = newnode(0);
  for (int i = 1; i <= n; i++) t[rt].child.push_back(newnode(1));
}
void print(int x) {
  if (leaf(x)) {
    ans[++pos] = x - 1;
    return;
  }
  for (int i = 0; i < int(t[x].child.size()); i++) print(t[x].child[i]);
}
void fix(int x) {
  vector<int> nchild;
  for (int i = 0; i < int(t[x].child.size()); i++) {
    int y = t[x].child[i];
    fix(y);
    while (int(t[y].child.size()) == 1) y = t[y].child[0];
    if (leaf(y) || !t[y].child.empty()) nchild.push_back(y);
  }
  t[x].child = nchild;
}
void dfs(int x, char *s) {
  if (leaf(x)) {
    t[x].full = (s[x - 1] == '1');
    t[x].empty = (s[x - 1] == '0');
    return;
  }
  t[x].full = t[x].empty = true;
  for (int i = 0; i < int(t[x].child.size()); i++) {
    int y = t[x].child[i];
    dfs(y, s);
    t[x].full &= t[y].full;
    t[x].empty &= t[y].empty;
  }
}
vector<int> split(int x) {
  vector<int> res;
  if (t[x].full || t[x].empty) {
    res.push_back(x);
    return res;
  }
  if (t[x].tp) {
    if (t[t[x].child[0]].empty || t[t[x].child.back()].full)
      reverse(t[x].child.begin(), t[x].child.end());
    int l = INF, r = -1;
    for (int i = 0; i < int(t[x].child.size()); i++)
      if (!t[t[x].child[i]].empty) l = min(l, i), r = max(r, i);
    if (l) EXIT("NO");
    for (int i = 0; i < int(t[x].child.size()); i++) {
      int y = t[x].child[i];
      if (!t[y].full && i >= l && i < r) EXIT("NO");
      if (t[y].full)
        res.push_back(y);
      else if (i == r) {
        vector<int> tmp = split(y);
        for (int j = 0; j < int(tmp.size()); j++) res.push_back(tmp[j]);
      } else
        res.push_back(y);
    }
  } else {
    int x0 = newnode(0), x1 = newnode(0);
    res.push_back(x1);
    bool f = false;
    for (int i = 0; i < int(t[x].child.size()); i++) {
      int y = t[x].child[i];
      if (!t[y].empty) {
        if (!t[y].full) {
          if (f) EXIT("NO");
          f = true;
          vector<int> tmp = split(y);
          for (int j = 0; j < int(tmp.size()); j++) res.push_back(tmp[j]);
        } else
          t[x1].child.push_back(y);
      } else
        t[x0].child.push_back(y);
    }
    res.push_back(x0);
  }
  return res;
}
void work(int x) {
  if (t[x].full || t[x].empty) return;
  if (t[x].tp) {
    vector<int> nchild;
    int l = INF, r = -1;
    for (int i = 0; i < int(t[x].child.size()); i++)
      if (!t[t[x].child[i]].empty) l = min(l, i), r = max(r, i);
    if (l == r) {
      work(t[x].child[l]);
      return;
    }
    for (int i = 0; i < int(t[x].child.size()); i++) {
      int y = t[x].child[i];
      if (!t[y].full && i > l && i < r) EXIT("NO");
      if (t[y].empty || t[y].full)
        nchild.push_back(y);
      else {
        vector<int> tmp = split(y);
        if (i == l)
          for (int j = int(tmp.size()) - 1; j >= 0; j--)
            nchild.push_back(tmp[j]);
        else
          for (int j = 0; j < int(tmp.size()); j++) nchild.push_back(tmp[j]);
      }
    }
    t[x].child = nchild;
  } else {
    int x0 = newnode(1), x1 = newnode(0), cnt = 0, tot = 0;
    for (int i = 0; i < int(t[x].child.size()); i++)
      tot += !t[t[x].child[i]].empty;
    vector<int> nchild;
    nchild.push_back(x0);
    for (int i = 0; i < int(t[x].child.size()); i++) {
      int y = t[x].child[i];
      if (t[y].empty)
        nchild.push_back(y);
      else {
        if (tot == 1) {
          work(y);
          return;
        }
        if (t[y].full)
          t[x1].child.push_back(y);
        else {
          cnt++;
          if (cnt > 2) EXIT("NO");
          vector<int> tmp = split(y);
          if (cnt == 1) {
            for (int j = int(tmp.size()) - 1; j >= 0; j--)
              t[x0].child.push_back(tmp[j]);
            t[x0].child.push_back(x1);
          } else
            for (int j = 0; j < int(tmp.size()); j++)
              t[x0].child.push_back(tmp[j]);
        }
      }
    }
    if (!cnt) nchild.push_back(x1);
    t[x].child = nchild;
  }
}
void run(char *s) {
  dfs(rt, s);
  work(rt);
  while (int(t[rt].child.size()) == 1) rt = t[rt].child[0];
  fix(rt);
}
}  // namespace PQ
int main() {
  scanf("%d", &n);
  PQ::init();
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
    PQ::run(s[i]);
  }
  puts("YES");
  PQ::print(PQ::rt);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) putchar(s[i][ans[j]]);
    putchar('\n');
  }
  return 0;
}