#include <bits/stdc++.h>
using namespace std;
vector<bool> sieve(long long n) {
  vector<bool> prime(n + 1, true);
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= n; i += p) {
        prime[i] = false;
      }
    }
  }
  prime[1] = false;
  return prime;
}
long long powerM(long long x, long long y) {
  if (y == 0) {
    return 1;
  }
  long long p = powerM(x, y / 2) % 1000000007;
  p = (p * p) % 1000000007;
  return (y % 2 == 0) ? p : (x * p) % 1000000007;
}
long long power(long long x, long long y) {
  if (y == 0) {
    return 1;
  }
  long long p = power(x, y / 2);
  p = (p * p);
  return (y % 2 == 0) ? p : (x * p);
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
bool isPalindrome(string s) {
  long long n = s.length();
  long long N = n % 2 == 0 ? n / 2 : n / 2 + 1;
  for (long long i = 0; i < N; i++) {
    if (s[i] != s[n - i - 1]) {
      return false;
    }
  }
  return true;
}
struct Comp {
  bool operator()(string a, string b) { return a.length() < b.length(); }
};
bool Substr(string s2, string s1) {
  long long counter = 0;
  long long i = 0;
  for (; i < s1.length(); i++) {
    if (counter == s2.length()) break;
    if (s2[counter] == s1[i]) {
      counter++;
    } else {
      if (counter > 0) {
        i -= counter;
      }
      counter = 0;
    }
  }
  return counter >= s2.length();
}
vector<string> solve(vector<string> a) {
  long long n = a.size();
  vector<string> ans;
  sort(a.begin(), a.end(), Comp());
  for (long long i = 0; i < n - 1; i++) {
    if (a[i].length() == a[i + 1].length()) {
      if (a[i] != a[i + 1]) {
        ans.clear();
        return ans;
      } else {
        ans.push_back(a[i]);
      }
    } else {
      if (!Substr(a[i], a[i + 1])) {
        ans.clear();
        return ans;
      } else {
        ans.push_back(a[i]);
      }
    }
  }
  ans.push_back(a[n - 1]);
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<string> a(n);
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<string> v = solve(a);
    if (v.size()) {
      cout << "YES\n";
      for (long long i = 0; i < v.size(); i++) {
        cout << v[i] << "\n";
      }
    } else {
      cout << "NO\n";
    }
  }
  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<bool> sieve(long long n) {
  vector<bool> prime(n + 1, true);
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= n; i += p) {
        prime[i] = false;
      }
    }
  }
  prime[1] = false;
  return prime;
}
long long powerM(long long x, long long y) {
  if (y == 0) {
    return 1;
  }
  long long p = powerM(x, y / 2) % 1000000007;
  p = (p * p) % 1000000007;
  return (y % 2 == 0) ? p : (x * p) % 1000000007;
}
long long power(long long x, long long y) {
  if (y == 0) {
    return 1;
  }
  long long p = power(x, y / 2);
  p = (p * p);
  return (y % 2 == 0) ? p : (x * p);
}
long long gcd(long long a, long long b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
bool isPalindrome(string s) {
  long long n = s.length();
  long long N = n % 2 == 0 ? n / 2 : n / 2 + 1;
  for (long long i = 0; i < N; i++) {
    if (s[i] != s[n - i - 1]) {
      return false;
    }
  }
  return true;
}
struct Comp {
  bool operator()(string a, string b) { return a.length() < b.length(); }
};
bool Substr(string s2, string s1) {
  long long counter = 0;
  long long i = 0;
  for (; i < s1.length(); i++) {
    if (counter == s2.length()) break;
    if (s2[counter] == s1[i]) {
      counter++;
    } else {
      if (counter > 0) {
        i -= counter;
      }
      counter = 0;
    }
  }
  return counter >= s2.length();
}
vector<string> solve(vector<string> a) {
  long long n = a.size();
  vector<string> ans;
  sort(a.begin(), a.end(), Comp());
  for (long long i = 0; i < n - 1; i++) {
    if (a[i].length() == a[i + 1].length()) {
      if (a[i] != a[i + 1]) {
        ans.clear();
        return ans;
      } else {
        ans.push_back(a[i]);
      }
    } else {
      if (!Substr(a[i], a[i + 1])) {
        ans.clear();
        return ans;
      } else {
        ans.push_back(a[i]);
      }
    }
  }
  ans.push_back(a[n - 1]);
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    vector<string> a(n);
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    vector<string> v = solve(a);
    if (v.size()) {
      cout << "YES\n";
      for (long long i = 0; i < v.size(); i++) {
        cout << v[i] << "\n";
      }
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}

```