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 \le n \le 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".

Difficulty: introductory

Starter code:

Solutions:
n = int(input())
arr = [input() for _ in range(n)]

arr.sort(key = lambda x : len(x))

for u, v in zip(arr[:-1], arr[1:]):
    if u not in v:
        print('NO')
        return

print('YES')
print('\n'.join(x for x in arr))

from functools import cmp_to_key
def mycmp(a, b):
    if a == b:
        return 0
    if a in b:
        return -1
    return 1

def main():
    n = int(input())
    a = [input() for _ in range(n)]
    poss = True
    for i in range(n):
        for j in range(i + 1, n):
            if a[i] not in a[j] and a[j] not in a[i]:
                poss = False
    if not poss:
        print('NO')
        return
    a.sort(key=cmp_to_key(mycmp))
    print('YES')
    for x in a:
        print(x)
main()


n = int(input())
ans = []
s = [input() for i in range(n)]
for i in range(n):
    for j in range(len(s)):
        t = True
        for k in range(len(s)):
            if j == k:
                continue
            if s[j] not in s[k]:
                t = False
                break
        if t:
            ans.append(s[j])
            del s[j]
            break
if len(ans) == n:
    print('YES')
    for i in ans:
        print(i)
else:
    print('NO')


n = int(input())
st = []
for i in range(n):
	st.append(input())

for i in range(n - 1):
	for j in range(i, n):
		if (not(st[i] in st[j])) and (not(st[j] in st[i])):
			print("NO")
			quit()
		if (st[j] in st[i]):
			wk1 = st[i]
			st[i] = st[j]
			st[j] = wk1

print("YES")
for i in st:
	print(i)


def go():
    n = int(input())
    s = []
    for i in range(n):
        s.append(input())
    s = sorted(s, key=lambda x: len(x))
    for i in range(n - 1):
        if s[i] not in s[i + 1]:
            print('NO')
            return
    print('YES')
    for i in range(n):
        print(s[i])

go()


def read_nums():
    return [int(x) for x in input().split()]


def is_good(strings):
    for i in range(1, len(strings)):
        if strings[i-1] not in strings[i]:
            return False
    return True


def main():
    n, = read_nums()
    strings = []
    for _ in range(n):
        strings.append(input())

    strings = sorted(strings, key=lambda x: len(x))
    if is_good(strings):
        print('YES')
        for s in strings:
            print(s)
    else:
        print('NO')


def __starting_point():
    main()

__starting_point()

N = int(input())
src = [input() for i in range(N)]
src.sort(key=lambda x:len(x))

for a,b in zip(src,src[1:]):
    if a in b: continue
    print('NO')
    return
print('YES')
for a in src:
    print(a)


n=int(input())
L=[input() for i in range(n)]
L.sort(key=len)
flag=True
for i in range(1,n):
    if L[i-1] not in L[i]:
        flag=False
        break
if flag:
    print("YES")
    for i in L:
        print(i)
else:
    print("NO")


n = int(input())
arr = []
for i in range(n):
    s = input()
    arr.append((len(s),s))
arr.sort()
fl = True
for i in range(n - 1):
    if arr[i + 1][1].find(arr[i][1]) == -1:
        fl = False
        break
if fl:
    print('YES')
    for i in arr:
        print(i[1])
else:
    print('NO')
'''
n, k = map(int, input().split())
arr = list(map(int, input().split()))
for i in range(n):
    arr[i] = (arr[i], i + 1)
arr.sort()

cur = -1
ans = []
for i in range(n):
    if arr[i][0] != cur:
        ans.append(arr[i][1])
        cur = arr[i][0]
    if len(ans) == k:
        break
if len(ans) == k:
    print('YES')
    print(*ans)
else:
    print('NO')
    '''

n=int(input())
s=[]
for x in range(n):
    e=input()
    s.append(e)
s=sorted(s,key=lambda x:len(x))
def issubstring(a,b):
    return b.count(a)
b=True
for x in range(n):
    for y in range(x):
        if(not issubstring(s[y],s[x])):
            b=False
if b:
    print("YES")
    for x in s:
        print(x)
else:
    print("NO")

n=int(input())
x=[0]*n
for i in range(n):
  x[i]=input()
x.sort(key=lambda x:len(x))
for i in range(n-1):
  for j in range(i+1,n):
    if x[i] not in x[j]:
      print('NO')
      return
print('YES')
for i in x:
  print(i)

n = int(input())
ss = []
for i in range(n):
    x = input().strip()
    ss.append(x)

ss = sorted(ss, key=len)
ok = True
i = 0
while i<len(ss)-1 and ok:
    if ss[i] not in ss[i+1]:
        ok = False
    i += 1
        
if not ok:
    print("NO")
else:
    print("YES")
    for x in ss:
        print(x)

n = int(input())
arr = []
for _ in range(n):
    s = input()
    arr.append(s)
arr.sort(key=len)
prev = ''
for s in arr:
    if prev not in s:
        print("NO")
        break
    prev = s
else:
    print("YES")
    print("\n".join(arr))


n = int(input())
a = [[] for i in range(110)]
for i in range(n):
    x = input()
    a[len(x)].append(x)
l = []
for i in a:
    for j in i:
        l.append(j)
x = l[0]
f = 1
#print(a,l)
for i in range(1,n):
    if(l[i].find(x)==-1):
        f = 0
    x = l[i]
if(f):
    print('YES')
    for i in l:
        print(i)
else:
    print('NO')

n = int(input())
a = []
for i in range(n):
    a.append(input())
b = [a[0]]
for j in range(1, n):
    b.append(a[j])
    c = len(b) - 1
    while c != 0 and b[c-1] not in b[c]:
        b[c-1], b[c] = b[c], b[c-1]
        c -= 1
flag  = True
for i in range(1, n):
    if b[i - 1] not in b[i]:
        flag = False

if flag:
    print("YES")
    for i in b:
        print(i)
else:
    print("NO")

n = int(input())
arr = []
for _ in range(n): arr.append(input())
arr.sort(key=len)
for i in range(n):
    for j in range(i, -1, -1):
        if arr[j] not in arr[i]:
            print("NO")
            return
print("YES")
print(*arr, sep='\n')

from copy import deepcopy
import itertools
from bisect import bisect_left
import math


def read():
    return int(input())


def readmap():
    return list(map(int, input().split()))


def readlist():
    return list(map(int, input().split()))


N = read()
string_list = []
for _ in range(N):
    s = input()
    string_list.append((len(s), s))

string_list.sort(key=lambda x: x[0])


def is_substring(a, b):  # a is shorter than b
    l_a = len(a)
    l_b = len(b)

    for i in range(l_b - l_a + 1):
        if a == b[i:i+l_a]:
            return True

    return False


for n in range(1, N):
    if not is_substring(string_list[n-1][1], string_list[n][1]):
        print("NO")
        quit()

print("YES")
for n in range(N):
    print(string_list[n][1])


d = []
for _ in range(int(input())):
    d.append(input())

d.sort(key = len)

for i in range(len(d) - 1, 0, -1):
    c, p = d[i], d[i-1]
    if p not in c:
        print('NO')
        return

print("YES")
print(*d, sep = '\n')


n = int(input())
a = [None] * n
for i in range(n):
    a[i] = input()
a.sort(key=len)
f = True
for i in range(n - 1):
    if a[i] not in a[i + 1]:
        f = False
        break
if f:
    print("YES")
    for i in range(n):
        print(a[i])
else:
    print("NO")

from math import log
from operator import itemgetter
n = int(input())
si = [[input(),0] for i in range(n)]
for i in range(n):
    si[i][1] = len(si[i][0])
si.sort(key=itemgetter(1))
ans = 1
for i in range(1,n):
    if si[i-1][0] not in si[i][0]:
        ans = 0
        break
if ans == 0:
    print("NO")
else:
    print("YES")
    for i in range(n):
        print(si[i][0])


n = int(input())

s = []
for i in range(n):
	s.append(input())

s.sort(key=len)

yes = True
for i in range(n-1):
	if s[i] not in s[i+1]:
		yes = False
		break

if yes:
	print("YES")
	print("\n".join(s))
else:
	print("NO")

n = int( input() )
l = []
for i in range( n ) :
    s = str( input() )
    l.append( [ len( s ) , s ] )
l.sort()
#print( l )
for i in range( n -1 ) :
    if l[ i ][1] not in l[ i + 1 ][1] :
        print( "NO" )
        return
print("YES")
for i in range( n ) :
    print( l[ i ][1] )
    


n=int(input())
a=[]
for i in range(n):
    x=input()
    a.append([len(x),x])
a=sorted(a)
for i in range(n-1):
    if not(a[i][-1]==a[i+1][-1] or a[i][-1] in a[i+1][-1]):
        print("NO")
        break
else:
    print("YES")
    for j in a:
        print(j[-1])

n = int(input())
s = [0] * n
ans = [0] * n
used = [0] * n
q = False
for i in range(n):
    s[i] = input().strip()
for i in range(n):
    for j in range(n):
        fl = True
        if (not used[j]):
            for k in range(n):
                if s[k] not in s[j]:
                    fl = False
            if fl:
                ans[i] = s[j]
                used[j] = 1
                s[j] = ''
                break
    if ans[i] == 0:
        q = True
if not q:
    print("YES")
    print(*ans[::-1], sep = '\n')
else:
    print("NO")