#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 9;
const long long mod1 = 1000000;
ostringstream convert;
long long n, m, cur, dp[100][300];
long long res;
long long nbb = 0, nss = 0, ncc = 0, wmin, wmax;
long long nb, ns, nc, pb, ps, pc, mx = 0;
string s, s2;
string a[1000];
long long vis[10000] = {0}, wpers[10000];
vector<string> v, vnode;
map<string, long long> mp;
set<long long> st;
stack<double> stk;
long long dx[] = {0, 1, -1, 0};
long long dy[] = {1, 0, 0, -1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long i, j = 1, k = 0, d, p, q, l, r, pos, idx = -1, nbx, sumf = 0, test;
  long long sum2 = 0, lg = 1, op;
  long long x, lastx = 0, val1 = 0;
  long long y = 1, z = 0;
  char c;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (k = 0; k <= 100; k++)
    for (i = 1; i <= n; i++) {
      s = a[i];
      j = 1;
      if (!vis[i])
        for (j = 1; j <= n; j++) {
          s2 = a[j];
          if (!vis[i] && !vis[j] && !strstr(s2.c_str(), s.c_str())) break;
        }
      if (j == n + 1) {
        v.push_back(s);
        vis[i] = 1;
      }
    }
  if (v.size() == n) {
    cout << "YES\n";
    for (i = 0; i < v.size(); i++) cout << v[i] << endl;
  } else
    cout << "NO";
}

### Prompt

Please provide a CPP coded solution to the problem described below:

You are given n strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings.

String a is a substring of string b if it is possible to choose several consecutive letters in b in such a way that they form a. For example, string "for" is contained as a substring in strings "codeforces", "for" and "therefore", but is not contained as a substring in strings "four", "fofo" and "rof".

Input

The first line contains an integer n (1 ≤ n ≤ 100) — the number of strings.

The next n lines contain the given strings. The number of letters in each string is from 1 to 100, inclusive. Each string consists of lowercase English letters.

Some strings might be equal.

Output

If it is impossible to reorder n given strings in required order, print "NO" (without quotes).

Otherwise print "YES" (without quotes) and n given strings in required order.

Examples

Input

5
a
aba
abacaba
ba
aba


Output

YES
a
ba
aba
aba
abacaba


Input

5
a
abacaba
ba
aba
abab


Output

NO


Input

3
qwerty
qwerty
qwerty


Output

YES
qwerty
qwerty
qwerty

Note

In the second example you cannot reorder the strings because the string "abab" is not a substring of the string "abacaba".

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 9;
const long long mod1 = 1000000;
ostringstream convert;
long long n, m, cur, dp[100][300];
long long res;
long long nbb = 0, nss = 0, ncc = 0, wmin, wmax;
long long nb, ns, nc, pb, ps, pc, mx = 0;
string s, s2;
string a[1000];
long long vis[10000] = {0}, wpers[10000];
vector<string> v, vnode;
map<string, long long> mp;
set<long long> st;
stack<double> stk;
long long dx[] = {0, 1, -1, 0};
long long dy[] = {1, 0, 0, -1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long i, j = 1, k = 0, d, p, q, l, r, pos, idx = -1, nbx, sumf = 0, test;
  long long sum2 = 0, lg = 1, op;
  long long x, lastx = 0, val1 = 0;
  long long y = 1, z = 0;
  char c;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (k = 0; k <= 100; k++)
    for (i = 1; i <= n; i++) {
      s = a[i];
      j = 1;
      if (!vis[i])
        for (j = 1; j <= n; j++) {
          s2 = a[j];
          if (!vis[i] && !vis[j] && !strstr(s2.c_str(), s.c_str())) break;
        }
      if (j == n + 1) {
        v.push_back(s);
        vis[i] = 1;
      }
    }
  if (v.size() == n) {
    cout << "YES\n";
    for (i = 0; i < v.size(); i++) cout << v[i] << endl;
  } else
    cout << "NO";
}

```