#include <bits/stdc++.h>
using namespace std;
long long pow2(long long k, long long h) {
  if (h == 0)
    return 1;
  else if (h == 1)
    return k;
  else {
    long long p = pow2(k, h / 2);
    p *= p;
    if (h % 2 == 1) p *= k;
    return p;
  }
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long bin(long long a, vector<long long>& s) {
  long long l = 0, r = s.size() - 1, j = 0, j2 = 0;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (s[mid] < a) {
      j = mid;
      l = mid + 1;
    } else if (s[mid] > a) {
      r = mid - 1;
    } else {
      return 0;
    }
  }
  return min(abs(a - s[j]), abs(a - s[j + 1]));
}
bool cmp(string a, string b) {
  if (a.size() < b.size())
    return 1;
  else
    return 0;
}
long long x[111][111];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t, n, k;
  cin >> t;
  vector<string> v;
  while (t--) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  bool ans = true;
  sort(v.begin(), v.end(), cmp);
  for (int i = 0; i < v.size() - 1; ++i) {
    string c = v[i + 1], cc = v[i];
    int g = 0, mm = 0;
    bool f = false;
    for (int j = 0; j < c.size(); ++j) {
      if (cc[g] == c[j]) {
        g++;
        if (g == cc.size()) break;
      } else {
        g = 0;
        j = mm;
        mm++;
      }
    }
    if (g < cc.size()) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i = 0; i < v.size(); ++i) cout << v[i] << "\n";
  return 0;
}

### Prompt

Generate 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;
long long pow2(long long k, long long h) {
  if (h == 0)
    return 1;
  else if (h == 1)
    return k;
  else {
    long long p = pow2(k, h / 2);
    p *= p;
    if (h % 2 == 1) p *= k;
    return p;
  }
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long bin(long long a, vector<long long>& s) {
  long long l = 0, r = s.size() - 1, j = 0, j2 = 0;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (s[mid] < a) {
      j = mid;
      l = mid + 1;
    } else if (s[mid] > a) {
      r = mid - 1;
    } else {
      return 0;
    }
  }
  return min(abs(a - s[j]), abs(a - s[j + 1]));
}
bool cmp(string a, string b) {
  if (a.size() < b.size())
    return 1;
  else
    return 0;
}
long long x[111][111];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t, n, k;
  cin >> t;
  vector<string> v;
  while (t--) {
    string s;
    cin >> s;
    v.push_back(s);
  }
  bool ans = true;
  sort(v.begin(), v.end(), cmp);
  for (int i = 0; i < v.size() - 1; ++i) {
    string c = v[i + 1], cc = v[i];
    int g = 0, mm = 0;
    bool f = false;
    for (int j = 0; j < c.size(); ++j) {
      if (cc[g] == c[j]) {
        g++;
        if (g == cc.size()) break;
      } else {
        g = 0;
        j = mm;
        mm++;
      }
    }
    if (g < cc.size()) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i = 0; i < v.size(); ++i) cout << v[i] << "\n";
  return 0;
}

```