#include <bits/stdc++.h>
using namespace std;
const int MX = 2e6 + 10;
const int mod = 1e9 + 7;
const long long int inf = 1LL << 62;
int dx4[] = {0, 0, -1, 1};
int dy4[] = {1, -1, 0, 0};
int dx[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[] = {1, 0, -1, 1, -1, 1, 0, -1};
vector<pair<int, string> > v;
map<long long int, vector<long long int> > mp;
int main() {
  long long int n, m, k, q, t, cnt = 0, sum = 0, ans = 0, mx = -inf, mn = inf,
                               a, b, c, d, e, f, g, h, i, j, x, y, z, temp,
                               temp1;
  string s, s1, s2, s3, *p;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    a = s.size();
    v.push_back(make_pair(a, s));
  }
  sort((v).begin(), (v).end());
  int len = v.size();
  s1 = v[0].second;
  for (i = 1; i < len; i++) {
    s = v[i].second;
    int len1 = s.length();
    int len2 = s1.length();
    for (int j = 0; j < len1; j++) {
      cnt = 0;
      if (s[j] == s1[0]) {
        z = j;
        for (int k = 0; k < len2; k++) {
          if (s1[k] != s[z]) {
            cnt = -1;
            break;
          }
          z++;
        }
        if (cnt == 0) {
          cnt = 1;
        }
      }
      if (cnt == 1) break;
    }
    if (cnt != 1) {
      ans = -1;
      break;
    }
    s1 = s;
  }
  if (ans == -1) {
    printf("NO\n");
  } else {
    printf("YES\n");
    for (i = 0; i < len; i++) {
      cout << v[i].second << endl;
    }
  }
  return 0;
}

### Prompt

Please formulate a Cpp solution to the following problem:

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 int MX = 2e6 + 10;
const int mod = 1e9 + 7;
const long long int inf = 1LL << 62;
int dx4[] = {0, 0, -1, 1};
int dy4[] = {1, -1, 0, 0};
int dx[] = {1, 1, 1, 0, 0, -1, -1, -1};
int dy[] = {1, 0, -1, 1, -1, 1, 0, -1};
vector<pair<int, string> > v;
map<long long int, vector<long long int> > mp;
int main() {
  long long int n, m, k, q, t, cnt = 0, sum = 0, ans = 0, mx = -inf, mn = inf,
                               a, b, c, d, e, f, g, h, i, j, x, y, z, temp,
                               temp1;
  string s, s1, s2, s3, *p;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    a = s.size();
    v.push_back(make_pair(a, s));
  }
  sort((v).begin(), (v).end());
  int len = v.size();
  s1 = v[0].second;
  for (i = 1; i < len; i++) {
    s = v[i].second;
    int len1 = s.length();
    int len2 = s1.length();
    for (int j = 0; j < len1; j++) {
      cnt = 0;
      if (s[j] == s1[0]) {
        z = j;
        for (int k = 0; k < len2; k++) {
          if (s1[k] != s[z]) {
            cnt = -1;
            break;
          }
          z++;
        }
        if (cnt == 0) {
          cnt = 1;
        }
      }
      if (cnt == 1) break;
    }
    if (cnt != 1) {
      ans = -1;
      break;
    }
    s1 = s;
  }
  if (ans == -1) {
    printf("NO\n");
  } else {
    printf("YES\n");
    for (i = 0; i < len; i++) {
      cout << v[i].second << endl;
    }
  }
  return 0;
}

```