#include <bits/stdc++.h>
long long fact[2000005];
long long inf = 1e18;
long long z = 1e9 + 7;
long long gdp(long long a, long long b) { return (a - (a % b)); }
long long ld(long long a, long long b) {
  if (a < 0) return -1 * gdp(abs(a), b);
  if (a % b == 0) return a;
  return (a + (b - a % b));
}
long long gd(long long a, long long b) {
  if (a < 0) return (-1 * ld(abs(a), b));
  return (a - (a % b));
}
long long gcd(long long a, long long b) {
  if (b > a) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long e_gcd(long long a, long long b, long long &x, long long &y) {
  if (b > a) return e_gcd(b, a, y, x);
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long x1, y1;
  e_gcd(b, a % b, x1, y1);
  x = y1;
  y = (x1 - ((a / b) * y1));
  return e_gcd(b, a % b, x1, y1);
}
long long power(long long a, long long b, long long p) {
  if (b == 0) return 1;
  long long c = power(a, b / 2, p);
  if (b % 2 == 0)
    return ((c * c) % p);
  else
    return ((((c * c) % p) * a) % p);
}
long long inverse(long long a, long long n) { return power(a, n - 2, n); }
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
long long left(long long i) { return ((2 * i) + 1); }
long long right(long long i) { return ((2 * i) + 2); }
long long ncr(long long n, long long r) {
  if (n < r || (n < 0) || (r < 0)) return 0;
  return ((((fact[n] * inverse(fact[r], z)) % z) * inverse(fact[n - r], z)) %
          z);
}
void swap(char &a, char &b) {
  char c = a;
  a = b;
  b = c;
  return;
}
long double pi = acos(-1);
long long pow(long long a, long long b) {
  if (b == 0) return 1;
  long long c = pow(a, b / 2);
  if (b % 2 == 0)
    return (c * c);
  else
    return ((c * c) * a);
}
using namespace std;
struct mytype {
  bool a;
  long long b;
};
const long long N = 1e5 + 15;
const long long M = 1e6 + 7;
bool check(string &a, string &b) {
  long long sz = a.size();
  for (long long i = 0; i + sz <= b.size(); i++) {
    string s = b.substr(i, sz);
    if (s == a) return true;
  }
  return false;
}
void solve() {
  long long n;
  cin >> n;
  vector<string> s(n);
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s.begin(), s.end(),
       [&](string a, string b) { return a.size() < b.size(); });
  bool ans = true;
  for (long long i = 1; i < n; i++) {
    ans = ans & check(s[i - 1], s[i]);
  }
  if (ans) {
    cout << "YES" << endl;
    for (auto x : s) cout << x << endl;
  } else {
    cout << "NO" << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}

### 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>
long long fact[2000005];
long long inf = 1e18;
long long z = 1e9 + 7;
long long gdp(long long a, long long b) { return (a - (a % b)); }
long long ld(long long a, long long b) {
  if (a < 0) return -1 * gdp(abs(a), b);
  if (a % b == 0) return a;
  return (a + (b - a % b));
}
long long gd(long long a, long long b) {
  if (a < 0) return (-1 * ld(abs(a), b));
  return (a - (a % b));
}
long long gcd(long long a, long long b) {
  if (b > a) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long e_gcd(long long a, long long b, long long &x, long long &y) {
  if (b > a) return e_gcd(b, a, y, x);
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long x1, y1;
  e_gcd(b, a % b, x1, y1);
  x = y1;
  y = (x1 - ((a / b) * y1));
  return e_gcd(b, a % b, x1, y1);
}
long long power(long long a, long long b, long long p) {
  if (b == 0) return 1;
  long long c = power(a, b / 2, p);
  if (b % 2 == 0)
    return ((c * c) % p);
  else
    return ((((c * c) % p) * a) % p);
}
long long inverse(long long a, long long n) { return power(a, n - 2, n); }
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
long long left(long long i) { return ((2 * i) + 1); }
long long right(long long i) { return ((2 * i) + 2); }
long long ncr(long long n, long long r) {
  if (n < r || (n < 0) || (r < 0)) return 0;
  return ((((fact[n] * inverse(fact[r], z)) % z) * inverse(fact[n - r], z)) %
          z);
}
void swap(char &a, char &b) {
  char c = a;
  a = b;
  b = c;
  return;
}
long double pi = acos(-1);
long long pow(long long a, long long b) {
  if (b == 0) return 1;
  long long c = pow(a, b / 2);
  if (b % 2 == 0)
    return (c * c);
  else
    return ((c * c) * a);
}
using namespace std;
struct mytype {
  bool a;
  long long b;
};
const long long N = 1e5 + 15;
const long long M = 1e6 + 7;
bool check(string &a, string &b) {
  long long sz = a.size();
  for (long long i = 0; i + sz <= b.size(); i++) {
    string s = b.substr(i, sz);
    if (s == a) return true;
  }
  return false;
}
void solve() {
  long long n;
  cin >> n;
  vector<string> s(n);
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s.begin(), s.end(),
       [&](string a, string b) { return a.size() < b.size(); });
  bool ans = true;
  for (long long i = 1; i < n; i++) {
    ans = ans & check(s[i - 1], s[i]);
  }
  if (ans) {
    cout << "YES" << endl;
    for (auto x : s) cout << x << endl;
  } else {
    cout << "NO" << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}

```