#include <bits/stdc++.h>
using namespace std;
vector<string> v;
vector<string> vec;
vector<string> vect;
vector<string> vecto;
map<string, int> seen;
int main() {
  int n, i, j, k, len, leng, len1, len2, len3, len4, add = 0, ok = 0;
  cin >> n;
  string x, y, z;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  len = v.size();
  for (i = 1; i <= 100; i++) {
    for (j = 0; j < len; j++) {
      if (v[j].size() == i) {
        vect.push_back(v[j]);
      }
    }
  }
  len4 = vect.size();
  for (i = 0; i < vect.size(); i++) {
    if (seen[vect[i]] == 0) {
      vecto.push_back(vect[i]);
    }
    seen[vect[i]]++;
  }
  leng = vecto.size();
  for (i = 1; i < leng; i++) {
    len1 = vecto[i - 1].size();
    y = vecto[i];
    len2 = y.size();
    if (len1 == len2) {
      if (vecto[i - 1] != y) {
        cout << "NO" << endl;
        goto end;
      }
    }
    for (j = 0; j <= len2 - len1; j++) {
      for (k = j; k < len1 + j; k++) {
        z = z + y[k];
        add++;
        if (add == len1) {
          vec.push_back(z);
          z.clear();
          add = 0;
          break;
        }
      }
    }
  }
  len3 = vec.size();
  for (i = 0; i < leng - 1; i++) {
    for (j = 0; j < len3; j++) {
      if (vecto[i] == vec[j]) {
        ok = 1;
        break;
      }
    }
    if (ok == 1) {
      ok = 0;
    } else {
      cout << "NO" << endl;
      goto end;
    }
  }
  cout << "YES" << endl;
  for (i = 0; i < len4; i++) {
    cout << vect[i] << endl;
  }
end:
  return 0;
}

### Prompt

Please create a solution in CPP 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;
vector<string> v;
vector<string> vec;
vector<string> vect;
vector<string> vecto;
map<string, int> seen;
int main() {
  int n, i, j, k, len, leng, len1, len2, len3, len4, add = 0, ok = 0;
  cin >> n;
  string x, y, z;
  for (i = 0; i < n; i++) {
    cin >> x;
    v.push_back(x);
  }
  len = v.size();
  for (i = 1; i <= 100; i++) {
    for (j = 0; j < len; j++) {
      if (v[j].size() == i) {
        vect.push_back(v[j]);
      }
    }
  }
  len4 = vect.size();
  for (i = 0; i < vect.size(); i++) {
    if (seen[vect[i]] == 0) {
      vecto.push_back(vect[i]);
    }
    seen[vect[i]]++;
  }
  leng = vecto.size();
  for (i = 1; i < leng; i++) {
    len1 = vecto[i - 1].size();
    y = vecto[i];
    len2 = y.size();
    if (len1 == len2) {
      if (vecto[i - 1] != y) {
        cout << "NO" << endl;
        goto end;
      }
    }
    for (j = 0; j <= len2 - len1; j++) {
      for (k = j; k < len1 + j; k++) {
        z = z + y[k];
        add++;
        if (add == len1) {
          vec.push_back(z);
          z.clear();
          add = 0;
          break;
        }
      }
    }
  }
  len3 = vec.size();
  for (i = 0; i < leng - 1; i++) {
    for (j = 0; j < len3; j++) {
      if (vecto[i] == vec[j]) {
        ok = 1;
        break;
      }
    }
    if (ok == 1) {
      ok = 0;
    } else {
      cout << "NO" << endl;
      goto end;
    }
  }
  cout << "YES" << endl;
  for (i = 0; i < len4; i++) {
    cout << vect[i] << endl;
  }
end:
  return 0;
}

```