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: EASY

Solutions:
n = int(input())
t = [input() for i in range(n)]
for i in range(n - 1):
	for j in range(i + 1, n):
		if len(t[j]) < len(t[i]):
			(t[i], t[j]) = (t[j], t[i])
h = True
for i in range(n - 1):
	if not t[i] in t[i + 1]:
		h = False
if h == True:
	print('YES')
	for i in range(n):
		print(t[i])
else:
	print('NO')


import re
n = int(input())
temp = []
count = 0
for i in range(n):
	a = str(input())
	temp.append(a)
new = sorted(temp, key=len)[::-1]
for x in range(len(new) - 1):
	if re.search(str(new[x + 1]), str(new[x])) == None:
		break
	elif re.search(str(new[x + 1]), str(new[x])) != None:
		count += 1
if count != len(new) - 1:
	print('NO')
elif count == len(new) - 1:
	print('YES')
	new = new[::-1]
	for x in new:
		print(x)


n = int(input())
a = []
for i in range(n):
	x = input()
	a.append(x)
a = sorted(a, key=len)
for i in range(len(a) - 1):
	if a[i] in a[i + 1]:
		continue
	else:
		print('NO')
		exit()
print('YES')
for i in range(len(a)):
	print(a[i])


TN = 1

def solution():
	n = int(input())
	l = []
	a = []
	d = {}
	ans = 1
	for i in range(n):
		l.append(input())
		a.append(len(l[i]))
		try:
			x = d[a[i]]
		except:
			d[a[i]] = l[i]
		else:
			if d[a[i]] != l[i]:
				ans = 0
	a = list(sorted(a))
	for i in range(1, n):
		for j in range(i):
			if d[a[j]] not in d[a[i]]:
				ans = 0
	if ans:
		print('YES')
		for i in a:
			print(d[i])
	else:
		print('NO')
while TN != 0:
	solution()
	TN -= 1


a = sorted([input() for i in range(int(input()))], key=lambda x: len(x))
print('YES\n' + '\n'.join(a) if all([a[i] in a[i + 1] for i in range(len(a) - 1)]) else 'NO')


n = int(input())
strings = []
for i in range(n):
	strings.append(input())
strings = sorted(strings, key=lambda x: len(x))
no = False
for i in range(1, len(strings)):
	if strings[i - 1] not in strings[i]:
		no = True
		break
if not no:
	print('YES')
	for i in strings:
		print(i)
else:
	print('NO')


n = int(input())
s = []
for i in range(n):
	s.append(input())
s = sorted(s, key=lambda x: len(x))
status = True
for i in range(0, len(s) - 1):
	if s[i] not in s[i + 1]:
		status = False
		break
if status:
	print('YES')
	for i in s:
		print(i)
else:
	print('NO')


n = int(input())
lis = []
for i in range(n):
	x = input()
	lis.append(x)
flag = 1
lis.sort(key=lambda s: len(s))
for i in range(n - 1):
	if lis[i] not in lis[i + 1]:
		flag = 0
		break
if flag == 1:
	print('YES')
	for i in range(n):
		print(lis[i])
else:
	print('NO')


from collections import defaultdict

def output(strs2, n):
	if len(strs2) != n:
		print('NO')
		return
	for i in range(n):
		for j in range(i + 1, n):
			if strs2[i] not in strs2[j]:
				print('NO')
				return
	print('YES')
	print('\n'.join(strs2))

def main():
	n = int(input())
	strs = []
	for i in range(n):
		strs.append(input())
	out_edge = defaultdict(set)
	in_edge = defaultdict(lambda : 0)
	for i in range(n):
		for j in range(i + 1, n):
			if strs[i] in strs[j] and strs[i] != strs[j]:
				out_edge[i].add(j)
				in_edge[j] += 1
			if strs[j] in strs[i] and strs[i] != strs[j]:
				out_edge[j].add(i)
				in_edge[i] += 1
	dq = [i for i in range(len(strs)) if in_edge[i] == 0]
	ans = dq[:]
	while dq:
		new_dq = []
		for src in dq:
			for dst in out_edge[src]:
				in_edge[dst] -= 1
				if in_edge[dst] == 0:
					new_dq.append(dst)
					ans.append(dst)
		dq = new_dq
	strs2 = [strs[i] for i in ans]
	output(strs2, n)
main()


n = int(input())
s = [input() for _ in range(n)]
s.sort(key=len)
valid = True
for i in range(1, n):
	if not s[i - 1] in s[i]:
		valid = False
		break
if valid:
	print('YES')
	print('\n'.join(s))
else:
	print('NO')


n = int(input())
li = []
Max = 0
for i in range(n):
	s = input()
	li.append(s)
isNo = False
li = list(reversed(sorted(li, key=len)))
curs = li[0]
for s in li:
	if s in curs:
		curs = s
	else:
		isNo = True
		break
if isNo:
	print('NO')
else:
	print('YES')
	for s in reversed(li):
		print(s)


a = []
for i in range(int(input())):
	a.append(input())
a.sort(key=len)
for i in range(1, len(a)):
	if a[i - 1] not in a[i]:
		print('NO')
		quit()
print('YES')
print('\n'.join(a))


n = int(input())
s = [input() for _ in range(n)]
s.sort(key=len)
if all((s[i] in s[i + 1] for i in range(n - 1))):
	print('YES')
	print(*s, sep='\n')
else:
	print('NO')


from collections import Counter
n = int(input())
strings = []
for i in range(n):
	strings.append(input())
strings.sort(key=lambda x: len(x))
for i in range(1, n):
	if strings[i - 1] not in strings[i]:
		print('NO')
		exit()
print('YES')
for s in strings:
	print(s)


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()


def main():
	n = int(input())
	s = []
	for i in range(n):
		s.append(input())
	s.sort(key=lambda x: len(x))
	ans = True
	for i in range(1, n):
		if s[i].find(s[i - 1]) == -1:
			ans = False
			break
	if ans:
		print('YES')
		for i in s:
			print(i)
	else:
		print('NO')
main()


a = int(input())
b = []
d = 0
for i in range(a):
	c = input()
	b.append(c)
b.sort(key=len)
for i in range(a - 1):
	if b[i + 1].find(b[i]) != -1:
		d += 1
	else:
		c = 1
		break
if d == a - 1:
	print('YES')
	for i in b:
		print(i)
else:
	print('NO')


n = int(input())
l = []
for i in range(n):
	l.append(str(input()))
l.sort(key=len)
flag = 0
for i in range(n - 1):
	if l[i] not in l[i + 1]:
		flag = 1
if flag == 1:
	print('NO')
else:
	print('YES')
	for x in l:
		print(x)


n = int(input())
s = []
for _ in range(n):
	s.append(input())
sorted_list = []
for i in range(n):
	min_count = 10000
	min_index = 0
	for x in range(len(s)):
		count = 0
		for y in range(len(s)):
			if s[y] in s[x]:
				count += 1
		if count < min_count:
			min_count = count
			min_index = x
	sorted_list.append(s[min_index])
	s.remove(s[min_index])
isSorted = True
for i in range(n - 1):
	if sorted_list[i] not in sorted_list[i + 1]:
		isSorted = False
		break
if isSorted:
	print('YES')
	for s in sorted_list:
		print(s)
else:
	print('NO')


o = int(input())
uk = []
gh = 0
uo = 0
for i in range(o):
	yu = input()
	if len(yu) > gh:
		gh = len(yu)
		uo = i
	uk.append(yu)
yk = 0
yj = {}
td = 0
uk.sort()
for i in range(len(uk) - 1):
	for j in range(i + 1, len(uk)):
		if len(uk[j]) < len(uk[i]):
			t = uk[j]
			uk[j] = uk[i]
			uk[i] = t
for i in range(1, len(uk)):
	j = i
	while j >= 0:
		if uk[i].count(uk[j]) == 0:
			td = 1
		j = j - 1
if td == 0:
	print('YES')
	for i in uk:
		print(i)
else:
	print('NO')


def is_sub(s1, s2):
	if len(s1) > len(s2):
		return False
	if len(s1) == len(s2) and s1 != s2:
		return False
	for i in range(len(s2) - len(s1) + 1):
		if s2[i:i + len(s1)] == s1:
			return True
	return False
n = int(input())
arr = [input() for _ in range(n)]
arr.sort(key=len)
f = False
for i in range(n - 1):
	if not is_sub(arr[i], arr[i + 1]):
		f = True
		break
if f:
	print('NO')
else:
	print('YES')
	for k in arr:
		print(k)


n = int(input())
s = [None] * n
for i in range(n):
	s[i] = input()
s = sorted(s, key=len)
if len(s) == 1:
	print('YES')
	print(s[0])
	exit()
for i in range(n - 1):
	l = len(s[i])
	boo = False
	for j in range(0, len(s[i + 1])):
		if s[i] == s[i + 1][j:l + j]:
			boo = True
	if not boo:
		print('NO')
		exit()
if boo:
	print('YES')
	for i in range(n):
		print(s[i])


n = int(input())
s = [input() for i in range(n)]
s = sorted(s, key=lambda x: len(x))
ok = True
for i in range(1, n):
	if not s[i - 1] in s[i]:
		ok = False
		break
if not ok:
	print('NO')
else:
	print('YES')
	print('\n'.join(s))


a = int(input())
b = []
for i in range(a):
	b.append(input())
b.sort(key=len)
for i in range(len(b)):
	for j in range(i, len(b)):
		if b[i] not in b[j]:
			print('NO')
			exit()
print('YES')
for i in b:
	print(i)


n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(s)
l.sort(key=len)
c = 0
for i in range(n - 1):
	if l[i] not in l[i + 1]:
		c = 1
if c == 1:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(l[i])


import sys
n = int(input())
b = [input() for x in range(n)]
b = sorted(b, key=len)
for x in range(n - 1):
	if b[x] not in b[x + 1]:
		print('NO')
		sys.exit()
print('YES')
print(*b, sep='\n')


def main():
	n = eval(input())
	lst = []
	for i in range(n):
		s = input()
		lst.append([len(s), s])
	lst.sort()
	result = True
	for i in range(n - 1):
		result = lst[i][1] in lst[i + 1][1]
		if not result:
			break
	if result:
		print('YES')
		for i in range(n):
			print(lst[i][1])
	else:
		print('NO')
main()


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])


a = int(input())
list1 = []
for i in range(0, a):
	list1.append(input())
for i in range(0, a):
	for j in range(i, a):
		if len(list1[i]) > len(list1[j]):
			(list1[i], list1[j]) = (list1[j], list1[i])
boo = True
for i in range(0, a - 1):
	if list1[i] in list1[i + 1]:
		continue
	else:
		boo = False
if boo:
	print('YES')
	for i in range(0, a):
		print(list1[i])
else:
	print('NO')


def main():
	n = int(input())
	strings = {}
	strings1 = {}
	S = []
	for i in range(n):
		s = input()
		strings[s] = 0
		if s in strings1:
			strings1[s] += 1
		else:
			strings1[s] = 1
		S.append(s)
	for s1 in S:
		for s2 in S:
			if s1.find(s2) == -1 and s2.find(s1) == -1:
				print('NO')
				return
	for cur_string in strings:
		for another_string in S:
			if cur_string != another_string and another_string.find(cur_string) != -1:
				strings[cur_string] += 1
	q = 0
	for s in strings:
		if strings[s] == 0:
			q += 1
			if q >= 2:
				break
	if q >= 2:
		print('NO')
		return
	print('YES')
	for x in sorted(strings.items(), key=lambda kv: (kv[1], kv[0]), reverse=True):
		for i in range(strings1[x[0]]):
			print(x[0])
main()


n = int(input())
L = []
for _ in range(n):
	x = input()
	L.append((len(x), x))
L.sort()
bad = False
for i in range(0, n - 1):
	if not L[i][1] in L[i + 1][1]:
		bad = True
if not bad:
	print('YES')
	for i in L:
		print(i[1])
else:
	print('NO')


n = int(input())
lst = []
for i in range(n):
	s = input()
	lst.append([len(s), s])
lst = sorted(lst)
a = lst[0][1]
for i in range(1, len(lst)):
	if a not in lst[i][1]:
		print('NO')
		break
	a = lst[i][1]
else:
	print('YES')
	for j in lst:
		print(j[1])


n = int(input())
s = []
for i in range(n):
	s.append(input())
d = [(len(_s), _s) for _s in s]
d.sort()
ok = True
for i in range(n - 1):
	if d[i][1] not in d[i + 1][1]:
		ok = False
if ok:
	print('YES')
	for i in range(n):
		print(d[i][1])
else:
	print('NO')


a = []
t = int(input())
for _ in range(t):
	a.append(input())
a = sorted(a, key=len)
for i in range(t - 1):
	if str(a[i]) in str(a[i + 1]):
		pass
	else:
		print('NO')
		exit()
print('YES')
for i in a:
	print(i)


n = int(input())
l = [input() for i in range(n)]
s = sorted(l, key=len)
for i in range(1, n):
	if s[i - 1] not in s[i]:
		print('NO')
		break
else:
	print('YES')
	for i in s:
		print(i)


n = int(input())
s = [0] * n
for i in range(n):
	s[i] = input()
cnt = [0] * n
for i in range(n):
	for j in range(n):
		if j != i and s[i] in s[j]:
			cnt[i] += 1
	cnt[i] = (cnt[i], s[i])
cnt = sorted(cnt)[::-1]
flag = 0
for i in range(n):
	if cnt[i][0] < n - 1 - i:
		flag = 1
		break
if flag:
	print('NO')
else:
	print('YES')
	for i in cnt:
		print(i[1])


__author__ = 'Esfandiar'
n = int(input())
a = list()
for i in range(n):
	a.append(input())
a.sort(key=len)
for i in range(n - 1):
	if a[i + 1].find(a[i]) == -1:
		print('NO')
		exit()
print('YES')
for i in range(n):
	print(a[i])


n = int(input())
strings = []
for i in range(n):
	s = input()
	strings.append(s)
sortedstrings = sorted(strings, key=lambda item: (len(item), item))
ok = True
for i in range(len(sortedstrings)):
	for j in range(i + 1, len(sortedstrings)):
		if not sortedstrings[i] in sortedstrings[j]:
			ok = False
			break
if not ok:
	print('NO')
else:
	print('YES')
	for s in sortedstrings:
		print(s)


n = int(input())
l = []
for i in range(n):
	s = input()
	l.append((len(s), s))
l.sort(key=lambda i: i[0])
ok = True
for i in range(1, n):
	if l[i][1].find(l[i - 1][1]) < 0:
		ok = False
		break
if ok:
	print('YES')
	for i in l:
		print(i[1])
else:
	print('NO')


n = int(input())
s = []
len = []
for i in range(n):
	s_ = input()
	s.append(s_)
	len.append(s_.__len__())
for i in range(n):
	for j in range(n - i - 1):
		if len[j] > len[j + 1]:
			a = len[j]
			len[j] = len[j + 1]
			len[j + 1] = a
			a = s[j]
			s[j] = s[j + 1]
			s[j + 1] = a
flag = 1
for i in range(n - 1):
	l = s[i + 1].split(s[i])[0].__len__()
	if l == len[i + 1]:
		flag = 0
		break
if flag == 0:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(s[i])


def custom_key(str):
	return len(str)
n = eval(input())
string = []
for i in range(n):
	string.append(input())
yes = 1
sortedList = sorted(string, key=custom_key)
for i in range(n - 1):
	if sortedList[i + 1].find(sortedList[i]) == -1:
		yes = 0
if yes == 1:
	print('YES')
	for i in range(n):
		print(sortedList[i])
else:
	print('NO')


n = int(input())
l = []
for i in range(n):
	a = input()
	l.append(a)
lenght = 100000000000
for i in range(n - 1):
	for j in range(n - i - 1):
		if len(l[j]) > len(l[j + 1]):
			(l[j], l[j + 1]) = (l[j + 1], l[j])
c = 1
for i in range(1, n):
	for j in range(i):
		if l[j] not in l[i]:
			c = 0
			break
	if not c:
		print('NO')
		break
if c:
	print('YES')
	for i in l:
		print(i)


n = int(input())
arr = []
for m in range(n):
	arr.append(input())
arr.sort(key=len)
flag = 0
for i in range(n - 1):
	if not arr[i] in arr[i + 1]:
		flag = 1
if flag == 1:
	print('NO')
else:
	print('YES')
	for l in arr:
		print(l)


n = int(input())
ls = []
for i in range(n):
	ls.append(input())
ls.sort(key=lambda x: (len(x), x))
for i in range(1, n):
	if ls[i].find(ls[i - 1]) == -1:
		print('NO')
		exit(0)
print('YES')
for s in ls:
	print(s)


n = int(input())
arr1 = []
arr2 = []
arr = []
k = 0
for i in range(n):
	s = str(input())
	g = len(s)
	arr1.append(s)
	arr2.append(g)
for i in range(n):
	arr.append(arr1[arr2.index(min(arr2))])
	arr2[arr2.index(min(arr2))] = 101
for i in range(n - 1):
	if not arr[i] in arr[i + 1]:
		print('NO')
		break
	else:
		k += 1
if k + 1 == n:
	print('YES')
	for i in range(n):
		print(arr[i])


n = int(input())
s = []
for i in range(n):
	s.append(input())
s.sort(key=len)
a = True
for i in range(n - 1):
	if not s[i] in s[i + 1]:
		print('NO')
		a = False
		break
if a:
	print('YES')
	for i in range(n):
		print(s[i])


n = int(input())
l1 = []
for i in range(n):
	s1 = input()
	l1.append(s1)
l1.sort(key=len)
count = 0
for i in range(len(l1)):
	if i == n - 1:
		break
	if l1[i + 1].count(l1[i]) == 0:
		count = 1
if count == 0:
	print('YES')
	for i in range(len(l1)):
		print(l1[i])
else:
	print('NO')


n = int(input())
string = []
for _ in range(n):
	s = input()
	string.append(s)
string = sorted(string, key=len)
ans = []
flg = 1
for i in range(1, n):
	if string[i - 1] not in string[i]:
		print('NO')
		flg = 0
		break
	else:
		ans.append(string[i - 1])
ans.append(string[n - 1])
if flg == 1:
	print('YES')
	print(*ans, sep='\n')


n = int(input())
arr = list()
for i in range(n):
	newstr = input().strip()
	arr.append(newstr)
l = [[len(ele), ele] for ele in arr]
l = list(sorted(l))
flag = 1
for i in range(0, n - 1):
	for j in range(i + 1, n):
		if l[i][1] not in l[j][1]:
			flag = 0
			break
	if flag == 0:
		break
if flag == 0:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(l[i][1])


l = []
flag = 0
n = int(input())
for xyz in range(0, n):
	s = input()
	l.append([len(s), s])
l.sort()
for i in range(0, n - 1):
	if l[i][0] < l[i + 1][0]:
		if l[i][1] not in l[i + 1][1]:
			flag = 1
			break
	elif l[i][1] != l[i + 1][1]:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in range(0, n):
		print(l[i][1])


def ordering(lst):
	z = sorted(lst, key=len)
	d = list()
	for i in range(len(z) - 1):
		if z[i] in z[i + 1]:
			d.append(z[i])
	if len(d) < len(z) - 1:
		return False
	return z
n = int(input())
a = list()
for j in range(n):
	s = input()
	a.append(s)
if ordering(a):
	print('YES')
	print(*ordering(a), sep='\n')
else:
	print('NO')


n = int(input())
A = []
for i in range(n):
	a = input()
	A.append((len(a), a))
A.sort()
B = []
for a in A:
	B.append(a[1])
good = True
for i in range(1, len(B)):
	if B[i - 1] not in B[i]:
		good = False
if good:
	print('YES')
	for b in B:
		print(b)
else:
	print('NO')


a = sorted([input() for _ in [0] * int(input())], key=lambda x: len(x))
r = any((x not in y for (x, y) in zip(a, a[1:])))
print('YNEOS'[r::2])
if r < 1:
	print(*a, sep='\n')


n = int(input())
strings = []
for i in range(n):
	strings.append(input())
strings.sort(key=len)
for i in range(n - 1):
	if strings[i] not in strings[i + 1]:
		print('NO')
		break
else:
	print('YES')
	for i in strings:
		print(i)


n = int(input())
s = []
l = []
f = []
for i in range(n):
	a = input()
	s.append(a)
	l.append(len(a))
	f.append(0)
l.sort()
ss = []
for i in range(n):
	for j in range(n):
		if len(s[j]) == l[i] and f[j] == 0:
			ss.append(s[j])
			f[j] = 1
			break
flag = 0
for i in range(len(ss)):
	for j in range(i + 1, len(ss)):
		if len(ss[j]) > len(ss[i]):
			break
		if ss[j] != ss[i]:
			flag = 1
			break
	if flag == 1:
		break
if flag == 1:
	print('NO')
else:
	for i in range(len(ss)):
		for j in range(i + 1, len(ss)):
			if ss[i] not in ss[j]:
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')
		for i in ss:
			print(i)


n = int(input())
string = list()
for i in range(n):
	string.append(input())
string.sort(key=len)
flag = 1
for i in range(len(string) - 1):
	if string[i] in string[i + 1]:
		continue
	else:
		flag = 0
		break
if flag:
	print('YES')
	for i in string:
		print(i)
else:
	print('NO')


n = int(input())
s = []
for i in range(0, n):
	s.append(input())
for i in range(n - 2, -1, -1):
	for j in range(0, i + 1):
		if not s[j] in s[j + 1]:
			(s[j], s[j + 1]) = (s[j + 1], s[j])
for i in range(0, n - 1):
	if not s[i] in s[i + 1]:
		print('NO')
		break
else:
	print('YES')
	for i in range(0, n):
		print(s[i])


L = []
for _ in range(int(input())):
	L.append(input())
L = sorted(L, key=lambda x: len(x))
for i in range(len(L) - 1):
	if L[i + 1].find(L[i]) == -1:
		print('NO')
		exit()
print('YES')
print('\n'.join(L))


from __future__ import division, print_function
import math
import os
import sys
from fractions import *
from sys import *
from decimal import *
from io import BytesIO, IOBase
from itertools import accumulate, combinations, permutations, combinations_with_replacement, product
from collections import *
import timeit, time
M = 10 ** 9 + 7
import heapq
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

def binarySearchcount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] == key:
			return mid
		if arr[mid] <= key:
			left = mid + 1
		else:
			right = mid - 1
	return -1

def ternarysearch(arr, n, key):
	(l, r) = (0, n - 1)
	while l <= r:
		mid = (-l + r) // 3 + l
		mid2 = mid + (-l + r) // 3
		if arr[mid] == key:
			return mid
		if arr[mid2] == key:
			return mid2
		if arr[mid] > key:
			r = mid - 1
		elif arr[mid2] < key:
			l = mid2 + 1
		else:
			l = mid + 1
			r = mid2 - 1
	return -1

def reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def soretd(s):
	for i in range(1, len(s)):
		if s[i - 1] > s[i]:
			return False
	return True

def countRhombi(h, w):
	ct = 0
	for i in range(2, h + 1, 2):
		for j in range(2, w + 1, 2):
			ct += (h - i + 1) * (w - j + 1)
	return ct

def countrhombi2(h, w):
	return h * h // 4 * (w * w // 4)

def binpow(a, b):
	if b == 0:
		return 1
	else:
		res = binpow(a, b // 2)
	if b % 2 != 0:
		return res * res * a
	else:
		return res * res

def binpowmodulus(a, b, m):
	a %= m
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b >>= 1
	return res

def coprime_to_n(n):
	result = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			result -= result // i
		i += 1
	if n > 1:
		result -= result // n
	return result

def luckynumwithequalnumberoffourandseven(x, n, a):
	if x >= n and str(x).count('4') == str(x).count('7'):
		a.append(x)
	elif x < 1000000000000.0:
		luckynumwithequalnumberoffourandseven(x * 10 + 4, n, a)
		luckynumwithequalnumberoffourandseven(x * 10 + 7, n, a)
	return a

def luckynum(x, l, r, a):
	if x >= l and x <= r:
		a.append(x)
	if x > r:
		a.append(x)
		return a
	if x < 10000000000.0:
		luckynum(x * 10 + 4, l, r, a)
		luckynum(x * 10 + 7, l, r, a)
	return a

def luckynuber(x, n, a):
	p = set(str(x))
	if len(p) <= 2:
		a.append(x)
	if x < n:
		luckynuber(x + 1, n, a)
	return a

def interact(type, x):
	if type == 'r':
		inp = input()
		return inp.strip()
	else:
		print(x, flush=True)

def findTrailingZeros(n):
	count = 0
	while n >= 5:
		n //= 5
		count += n
	return count

def mergeSort(arr):
	if len(arr) > 1:
		mid = len(arr) // 2
		L = arr[:mid]
		R = arr[mid:]
		mergeSort(L)
		mergeSort(R)
		i = j = k = 0
		while i < len(L) and j < len(R):
			if L[i] < R[j]:
				arr[k] = L[i]
				i += 1
			else:
				arr[k] = R[j]
				j += 1
			k += 1
		while i < len(L):
			arr[k] = L[i]
			i += 1
			k += 1
		while j < len(R):
			arr[k] = R[j]
			j += 1
			k += 1
res = set()

def solven(p, l, a, b, n):
	if p > n or l > 10:
		return
	if p > 0:
		res.add(p)
	solven(p * 10 + a, l + 1, a, b, n)
	solven(p * 10 + b, l + 1, a, b, n)

def subsetsUtil(A, subset, index, d):
	print(*subset)
	s = sum(subset)
	d.append(s)
	for i in range(index, len(A)):
		subset.append(A[i])
		subsetsUtil(A, subset, i + 1, d)
		subset.pop(-1)
	return d

def subsetSums(arr, l, r, d, sum=0):
	if l > r:
		d.append(sum)
		return
	subsetSums(arr, l + 1, r, d, sum + arr[l])
	subsetSums(arr, l + 1, r, d, sum)
	return d

def print_factors(x):
	factors = []
	for i in range(1, x + 1):
		if x % i == 0:
			factors.append(i)
	return factors

def calc(X, d, ans, D):
	if len(X) == 0:
		return
	i = X.index(max(X))
	ans[D[max(X)]] = d
	Y = X[:i]
	Z = X[i + 1:]
	calc(Y, d + 1, ans, D)
	calc(Z, d + 1, ans, D)

def factorization(n, l):
	c = n
	if prime(n) == True:
		l.append(n)
		return l
	for i in range(2, c):
		if n == 1:
			break
		while n % i == 0:
			l.append(i)
			n = n // i
	return l

def good(b):
	l = []
	i = 0
	while len(b) != 0:
		if b[i] < b[len(b) - 1 - i]:
			l.append(b[i])
			b.remove(b[i])
		else:
			l.append(b[len(b) - 1 - i])
			b.remove(b[len(b) - 1 - i])
	if l == sorted(l):
		return True
	return False

def generate(st, s):
	if len(s) == 0:
		return
	if s not in st:
		st.add(s)
		for i in range(len(s)):
			t = list(s).copy()
			t.remove(s[i])
			t = ''.join(t)
			generate(st, t)
	return

def largestincreasingsubsequence(A):
	l = [1] * len(A)
	sub = []
	for i in range(1, len(l)):
		for k in range(i):
			if A[k] < A[i]:
				sub.append(l[k])
		l[i] = 1 + max(sub, default=0)
	return max(l, default=0)

def findOR(nums, N):
	prefix_sum = 0
	result = 0
	for i in range(N):
		result |= nums[i]
		prefix_sum += nums[i]
		result |= prefix_sum
	return result

def OR(a, n):
	ans = a[0]
	for i in range(1, n):
		ans |= a[i]
	return ans

def toString(List):
	return ''.join(List)

def permute(a, l, r, p):
	if l == r:
		p.append(toString(a))
	else:
		for i in range(l, r + 1):
			(a[l], a[i]) = (a[i], a[l])
			permute(a, l + 1, r, p)
			(a[l], a[i]) = (a[i], a[l])

def squareRoot(number, precision):
	start = 0
	(end, ans) = (number, 1)
	while start <= end:
		mid = int((start + end) / 2)
		if mid * mid == number:
			ans = mid
			break
		if mid * mid < number:
			start = mid + 1
		else:
			end = mid - 1
	increment = 0.1
	for i in range(0, precision):
		while ans * ans <= number:
			ans += increment
		ans = ans - increment
		increment = increment / 10
	return ans

def countRectangles(l, w):
	squareSide = math.gcd(l, w)
	return int(l * w / (squareSide * squareSide))

def count_same_digit(L, R):
	tmp = 0
	ans = 0
	n = int(math.log10(R) + 1)
	for i in range(0, n):
		tmp = tmp * 10 + 1
		for j in range(1, 10):
			if L <= tmp * j and tmp * j <= R:
				ans += 1
	return ans

def findCrossOver(arr, low, high, x):
	if arr[high] <= x:
		return high
	if arr[low] > x:
		return low
	mid = (low + high) // 2
	if arr[mid] <= x and arr[mid + 1] > x:
		return mid
	if arr[mid] < x:
		return findCrossOver(arr, mid + 1, high, x)
	return findCrossOver(arr, low, mid - 1, x)

def Kclosest(arr, x, k, n, ans):
	l = findCrossOver(arr, 0, n - 1, x)
	r = l + 1
	count = 0
	if arr[l] == x:
		l -= 1
	while l >= 0 and r < n and (count < k):
		if x - arr[l] < arr[r] - x:
			ans.append(arr[l])
			l -= 1
		else:
			ans.append(arr[r])
			r += 1
		count += 1
	while count < k and l >= 0:
		ans.append(arr[l])
		l -= 1
		count += 1
	while count < k and r < n:
		ans.append(arr[r])
		r += 1
		count += 1
	return ans

def prime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n)) + 1, 2):
		if n % i == 0:
			return False
	return True

def calcSum(arr, n, k):
	l = []
	sum = 0
	for i in range(k):
		sum += arr[i]
	l.append(sum)
	for i in range(k, n):
		sum = sum - arr[i - k] + arr[i]
		l.append(sum)
	return l

def dfs(root, nodeVal, nodeConnection, visited):
	leftVal = nodeVal[root][0]
	rightVal = nodeVal[root][1]
	solution = []
	if nodeConnection[root]:
		visited.add(root)
		for i in nodeConnection[root]:
			if i not in visited:
				solution.append(dfs(i, nodeVal, nodeConnection, visited))
		leftMax = 0
		rightMax = 0
		for i in solution:
			(l, r) = i
			leftMax += max(abs(leftVal - l[0]) + l[1], abs(leftVal - r[0]) + r[1])
			rightMax += max(abs(rightVal - l[0]) + l[1], abs(rightVal - r[0]) + r[1])
		return ((leftVal, leftMax), (rightVal, rightMax))
	else:
		return ((leftVal, 0), (rightVal, 0))

def luckynumber(x, n, a):
	if x > 0:
		a.append(x)
	if x > 10 ** 9:
		return a
	elif x < 1000000000000.0:
		luckynumber(x * 10 + 4, n, a)
		luckynumber(x * 10 + 7, n, a)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def query(l, r):
	if l >= r:
		return -1
	print('?', l + 1, r + 1)
	sys.stdout.flush()
	return int(input()) - 1

def answer(p):
	print('!', p + 1)
	sys.stdout.flush()
	exit()

def main():
	n = inpu()
	l = []
	for i in range(n):
		s = inp()
		l.append([len(s), s])
	l.sort()
	for i in range(1, len(l)):
		if l[i - 1][1] in l[i][1]:
			continue
		else:
			print('NO')
			break
	else:
		print('YES')
		for i in range(len(l)):
			print(l[i][1])
main()


n = int(input())
l = []
for _ in range(n):
	s = input()
	l.append(s)
l.sort(key=len)
flg = 0
for i in range(n - 1):
	if l[i + 1].find(l[i]) == -1:
		flg = 1
		break
if flg == 1:
	print('NO')
else:
	print('YES')
	for i in l:
		print(i)


a = sorted([input() for i in range(int(input()))], key=lambda x: len(x))
b = [i for (i, j) in zip(a, a[1:]) if i in j] + a[-1:]
print(*(('YES', *b), ('NO',))[len(b) < len(a)], sep='\n')


n = int(input())
a = [input() for _ in range(n)]
a.sort(key=len)
for i in range(n - 1):
	if a[i] not in a[i + 1]:
		print('NO')
		exit(0)
print('YES')
for i in a:
	print(i)


def cmp(x):
	return len(x)
n = int(input())
a = sorted([input() for i in range(n)], key=cmp)
for i in range(n - 1):
	if a[i] not in a[i + 1]:
		print('NO')
		exit(0)
print('YES')
for i in a:
	print(i)


a = int(input())
t = []
l = []
for i in range(a):
	b = input()
	t.append(b)
	l.append(len(b))
t_sorted = sorted(range(len(l)), key=lambda x: l[x])
i = 0
while i < int(len(t_sorted) - 1):
	if str(t[int(t_sorted[i])]) in str(t[int(t_sorted[i + 1])]):
		i += 1
	else:
		break
if i < len(t_sorted) - 1:
	print('NO')
else:
	print('YES')
	for i in range(len(t_sorted)):
		print(t[int(t_sorted[i])])


def main():
	n = int(input())
	s = []
	for _ in range(n):
		s.append(input())
	for i in range(n - 1):
		for j in range(i + 1, n):
			if len(s[j]) < len(s[i]):
				(s[i], s[j]) = (s[j], s[i])
	ok = True
	for i in range(n - 1):
		for j in range(i + 1, n):
			if s[i] not in s[j]:
				ok = False
				break
	if not ok:
		print('NO')
	else:
		print('YES')
		for val in s:
			print(val)
main()


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

def Sorting(lst):
	lst2 = sorted(lst, key=len)
	return lst2
b = Sorting(a)
count = 1
for i in range(n - 1):
	if b[i] in b[i + 1]:
		count += 1
if count == n:
	print('YES')
	for i in range(n):
		print(b[i])
else:
	print('NO')


a = int(input())
z = []
q = 0
p = 0
for i in range(a):
	z.append(input())
for i in range(a):
	for j in range(i + 1, a):
		if len(z[i]) > len(z[j]):
			(z[i], z[j]) = (z[j], z[i])
if len(z) == 1:
	print('YES')
	print(z[0])
	p = 11
else:
	for i in range(1, a):
		if z[i].find(z[i - 1]) != -1:
			q += 1
if q == a - 1 and p != 11:
	print('YES')
	for i in z:
		print(i)
elif p != 11:
	print('NO')


t = int(input())
s = []
slen = []
n = t
while t:
	t -= 1
	s1 = input()
	s.append(s1)
	slen.append(len(s1))
slen.sort()
new_s = []
k = 0
for i in range(n):
	for x in s:
		if len(x) == slen[k]:
			new_s.append(x)
			k += 1
			s.remove(x)
			break
		else:
			continue
z = 0
for i in range(n - 1):
	if new_s[i] in new_s[i + 1]:
		continue
	else:
		z = 1
		break
if z == 1:
	print('NO')
else:
	print('YES')
	for x in new_s:
		print(x)


n = int(input())
a = []
for i in range(n):
	s = input()
	fl = True
	k = len(s)
	for j in range(i):
		if len(a[j]) >= k:
			a.insert(j, s)
			fl = False
			break
	if fl:
		a.append(s)
f = True
for i in range(len(a) - 1):
	if a[i] not in a[i + 1]:
		f = False
		print('NO')
		break
if f:
	print('YES')
	for i in range(len(a)):
		print(a[i])


def merge(arr, temp, l, m, r):
	n1 = m - l + 1
	n2 = r - m
	L1 = [0] * n1
	L2 = [''] * n1
	R1 = [0] * n2
	R2 = [''] * n2
	for i in range(0, n1):
		L1[i] = arr[l + i]
		L2[i] = temp[l + i]
	for j in range(0, n2):
		R1[j] = arr[m + 1 + j]
		R2[j] = temp[m + 1 + j]
	i = 0
	j = 0
	k = l
	while i < n1 and j < n2:
		if L1[i] <= R1[j]:
			arr[k] = L1[i]
			temp[k] = L2[i]
			i += 1
		else:
			arr[k] = R1[j]
			temp[k] = R2[j]
			j += 1
		k += 1
	while i < n1:
		arr[k] = L1[i]
		temp[k] = L2[i]
		i += 1
		k += 1
	while j < n2:
		arr[k] = R1[j]
		temp[k] = R2[j]
		j += 1
		k += 1

def mergeSort(arr, temp, l, r):
	if l < r:
		m = (l + (r - 1)) // 2
		mergeSort(arr, temp, l, m)
		mergeSort(arr, temp, m + 1, r)
		merge(arr, temp, l, m, r)
n = int(input())
arr = []
temp = []
for i in range(n):
	s = str(input())
	arr.append(len(s))
	temp.append(s)
mergeSort(arr, temp, 0, n - 1)
flag = 0
for i in range(1, n):
	if temp[i - 1] in temp[i]:
		pass
	else:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(temp[i])


arr = []
for _ in range(int(input())):
	arr.append(input())
arr.sort(key=len)
flag = 0
for i in range(1, len(arr)):
	if len(arr[i - 1]) == len(arr[i]):
		if arr[i - 1] != arr[i]:
			flag = 1
			break
	elif arr[i - 1] not in arr[i]:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in range(len(arr)):
		print(arr[i])


n = int(input())
str_list = []
for _ in range(n):
	str_list.append(str(input()))
str_list = sorted(str_list, key=len)
counter = 0
for _ in range(n - 1):
	(a, b) = (str_list[counter], str_list[counter + 1])
	if a not in b:
		print('NO')
		quit()
	counter += 1
print('YES')
print(*str_list, sep='\n')


n = int(input())
a = []
for i in range(n):
	a.append(input())
a = sorted(a, key=len)
for i in range(n - 1):
	if a[i] not in a[i + 1]:
		print('NO')
		exit(0)
print('YES')
for i in range(n):
	print(a[i])


import re
import math
import decimal
import bisect

def read():
	return input().strip()

def iread():
	return int(input().strip())

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

def cmp(a, b):
	if a in b or a == b:
		return -1
	else:
		return 1

def cmp_to_key(mycmp):

	class K(object):

		def __init__(self, obj, *args):
			self.obj = obj

		def __lt__(self, other):
			return mycmp(self.obj, other.obj) < 0

		def __gt__(self, other):
			return mycmp(self.obj, other.obj) > 0

		def __eq__(self, other):
			return mycmp(self.obj, other.obj) == 0

		def __le__(self, other):
			return mycmp(self.obj, other.obj) <= 0

		def __ge__(self, other):
			return mycmp(self.obj, other.obj) >= 0

		def __ne__(self, other):
			return mycmp(self.obj, other.obj) != 0
	return K
n = iread()
words = []
for i in range(n):
	words.append(read())
words.sort(key=cmp_to_key(cmp))
for i in range(1, n):
	if words[i - 1] not in words[i]:
		print('NO')
		exit(0)
print('YES', *words, sep='\n')


n = int(input())
new = []
a = []
for i in range(0, n):
	e = input()
	a.append(e)
new = sorted(a, key=len)
flag = True
for i in range(1, n):
	if new[i - 1] not in new[i]:
		flag = False
		break
if flag:
	print('YES')
	for i in new:
		print(i)
else:
	print('NO')


n = int(input())
s = [input() for _ in range(n)]
s = list(sorted(s, key=lambda p: len(p)))
for i in range(1, n):
	if s[i].find(s[i - 1]) == -1:
		print('NO')
		break
else:
	print('YES', *s, sep='\n')


def substring_sort(slist):
	if slist is None:
		return 'NO'
	lengths = [len(x) for x in slist]
	sortedxs = sorted(slist, key=len)
	mxlenstr = sortedxs[-1]
	ok = True
	for x in range(0, len(sortedxs) - 1):
		if str(sortedxs[x + 1]).find(str(sortedxs[x])) == -1:
			ok = False
	if not ok:
		return ('NO', None)
	else:
		return ('YES', sortedxs)
n = int(input())
ls = []
for i in range(n):
	ls.append(str(input()))
(res, sorte) = substring_sort(ls)
print(res)
if sorte is not None:
	for x in sorte:
		print(x)


n = int(input())
a = []
for i in range(n):
	a.append(input())
impossible = False
for i in range(n):
	for j in range(n - i - 1):
		if a[j + 1] in a[j]:
			temp = a[j + 1]
			a[j + 1] = a[j]
			a[j] = temp
		elif a[j] in a[j + 1]:
			pass
		else:
			impossible = True
		if impossible:
			break
	if impossible:
		break
if impossible:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(a[i])


A = sorted((input() for _ in range(int(input()))), key=len)
for (a, b) in zip(A, A[1:]):
	if a not in b:
		print('NO')
		break
else:
	print('YES', *A, sep='\n')


m = int(input())
ss = []
for i in range(m):
	ptr = ''
	ptr = input()
	ss = ss + [ptr]
counter = []
list = []
dic = {}
for i in ss:
	flag = 0
	for j in ss:
		if i in j:
			flag += 1
	counter += [flag]
	if flag not in list:
		dic[flag] = [i]
		list += [flag]
	else:
		dic[flag] += [i]
counter.sort()
tmp = 1
for i in range(m):
	if counter[i] < i + 1:
		tmp = 0
if tmp == 1:
	print('YES')
	list.sort()
	list.reverse()
	for i in list:
		for j in dic[i]:
			print(j)
else:
	print('NO')


import sys
n = int(input())
ss = list()
for i in range(n):
	ss.append(input())

def contains(a, b):
	if a in b:
		return True
	return False
ss = sorted(ss, key=len)
res = list()
for i in range(len(ss) - 1):
	if contains(ss[i], ss[i + 1]):
		res.append(ss[i])
res.append(ss[-1])
if len(res) == len(ss):
	print('YES')
	for i in res:
		print(i)
else:
	print('NO')


n = int(input())
li = [input() for i in range(n)]
li = sorted(li, key=len)
GOT = True
for i in range(n - 1):
	if li[i] not in li[i + 1]:
		GOT = False
		break
if GOT:
	print('YES')
	for i in li:
		print(i)
else:
	print('NO')


try:
	n = int(input())
	a = []
	for i in range(n):
		a.append(input())
	a = sorted(a, key=len)
	if n == 1:
		print('YES')
		print(a[0])
	for i in range(1, n):
		if a[i].count(a[i - 1]) >= 1:
			if i == n - 1:
				print('YES')
				for ele in a:
					print(ele)
		else:
			print('NO')
			break
except:
	pass


import re
n = int(input())
l = sorted([input() for _ in range(n)], key=lambda s: len(s))
res = True
for i in range(n):
	res &= all((l[i] in l[j] for j in range(i, n)))
if res:
	print('YES')
	print(*l, sep='\n')
else:
	print('NO')


def f():
	for i in range(len(l) - 1):
		if l[i] not in l[i + 1]:
			return False
	return True
n = int(input())
l = sorted([input() for i in range(n)], key=len)
if f():
	print('YES')
	for i in l:
		print(i)
else:
	print('NO')


def calLen(string):
	return len(string)
n = int(input())
input_string_arr = []
for i in range(0, n):
	input_string = input()
	input_string_arr.append(input_string)
input_string_arr.sort(key=calLen)
fault = False
for i in range(0, len(input_string_arr) - 1):
	if not input_string_arr[i] in input_string_arr[i + 1]:
		fault = True
		break
if fault == True:
	print('NO')
else:
	print('YES')
	for i in range(0, len(input_string_arr)):
		print(input_string_arr[i])


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

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

def readmap():
	return 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):
	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])


n = int(input())
arr = []
i = 0
index = 0
maxx = 0
while n:
	strr = input()
	arr.append(strr)
	n -= 1
flag = 0
arr = sorted(arr, key=len)
content = arr[-1]
for i in range(1, len(arr)):
	if arr[i - 1] in arr[i]:
		pass
	else:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for e in arr:
		print(e)


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')
			exit()
print('YES')
print(*arr, sep='\n')


def main():
	n = int(input())
	array = [input() for _ in range(n)]
	array.sort(key=len)
	for i in range(1, len(array)):
		if array[i - 1] in array[i]:
			continue
		print('NO')
		return
	print('YES')
	for el in array:
		print(el)
main()


n = int(input())
a = []
for i in range(n):
	x = input()
	a.append([len(x), x])
a = sorted(a)
cnt = 0
for i in range(1, n):
	if a[i - 1][1] in a[i][1]:
		cnt += 1
if cnt == n - 1:
	print('YES')
	for i in range(n):
		print(a[i][1])
else:
	print('NO')


k = int(input())
lis = []
p = 0
for i in range(k):
	m = input()
	a = [len(m), m]
	lis.append(a)
lis.sort()
for i in range(k - 1):
	if lis[i + 1][1].find(lis[i][1]) == -1:
		print('NO')
		p = 1
		break
if p == 0:
	print('YES')
	for i in range(k):
		print(lis[i][1])


n = int(input().strip())
a = []
for i in range(n):
	a.append(input().strip())
a = sorted(a, key=lambda x: len(x))
flag = True
for i in range(n - 1):
	if a[i] not in a[i + 1]:
		flag = False
		break
if flag:
	print('YES')
	print('\n'.join(a))
else:
	print('NO')


n = int(input())
s = []
m = []
r = []
f = 0
for i in range(n):
	s.append(input())
	m.append(len(s[i]))
temp = min(m)
index = m.index(temp)
r.append(s[index])
m.remove(temp)
s.remove(s[index])
for i in range(1, n):
	temp = min(m)
	index = m.index(temp)
	r.append(s[index])
	if r[i - 1] not in r[i]:
		f = 1
	m.remove(temp)
	s.remove(s[index])
if f == 1:
	print('NO')
else:
	print('YES')
	for t in r:
		print(t)


import operator
n = int(input())
strs = []
for i in range(n):
	strs.append(input())
data = [strs[0]]
size = 1
is_valid = True
for i in strs[1:]:
	point = size
	while point > 0 and i.find(data[point - 1]) >= 0:
		point -= 1
	data.insert(point, i)
	is_valid = True
	for ii in data[0:point]:
		if ii.find(i) < 0:
			is_valid = False
			print('NO')
			break
	if not is_valid:
		break
	size += 1
if is_valid:
	print('YES')
	for i in reversed(data):
		print(i)


n = int(input())
lst = []
for i in range(n):
	s = input()
	lst.append(s)
lst.sort(key=len)
c = 1
for i in range(len(lst)):
	c = 1
	for j in range(i + 1, len(lst)):
		if lst[j].count(lst[i]) == 0:
			c = 0
			break
	if c == 0:
		break
if c == 0:
	print('NO')
else:
	print('YES')
	for i in range(len(lst)):
		print(lst[i])


a = []
for tc in range(int(input())):
	a.append(input())
a.sort(key=lambda i: len(i))
f = 1
for i in range(len(a) - 1):
	if a[i] not in a[i + 1]:
		f = 0
		break
if not f:
	print('NO')
else:
	print('YES')
	for i in a:
		print(i)


strings = []
n = int(input())
for i in range(n):
	s = input()
	strings.append(s)
strings.sort(key=lambda x: len(x))
poss = True
for i in range(n - 1):
	s = strings[i]
	if not s in strings[i + 1]:
		poss = False
		break
if not poss:
	print('NO')
else:
	print('YES')
	print('\n'.join(strings))


from sys import stdin, stdout
for _ in range(1):
	n = int(stdin.readline())
	s = []
	for i in range(n):
		s += [input()]
	s.sort(key=lambda x: (len(x), x))
	f = 1
	for (s1, s2) in zip(s, s[1:]):
		if s1 not in s2:
			f = 0
			break
	if f == 0:
		print('NO')
	else:
		print('YES')
		for ss in s:
			print(ss)


def f(s):
	return len(s)
n = int(input())
a = []
for i in range(n):
	a.append(input())
a.sort(key=f)
ans = 'YES'
for i in range(n - 1):
	if not a[i] in a[i + 1]:
		ans = 'NO'
		break
print(ans)
if ans == 'YES':
	for s in a:
		print(s)


n = int(input())
s = []
for i in range(n):
	s.append(input())
s.sort(key=lambda st: len(st))
for i in range(n - 1):
	if s[i] not in s[i + 1]:
		print('NO')
		exit(0)
print('YES')
print(*s, sep='\n')


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())
kam = []
l = []
s = []
count = 0
kj = []
for x in range(n):
	p = input()
	kam.append(p)
	l.append(len(p))
for x in range(len(l)):
	n = l.index(min(l))
	s.append(kam[n])
	kj.append(kam[n])
	l[n] = 555
for item in s[0:len(s) - 1]:
	po = s.index(item)
	if item in s[po + 1]:
		s[po] = '5656'
		pass
	else:
		count = 1
		print('NO')
		break
if count == 0:
	print('YES')
	for item in kj:
		print(item)


n = int(input())
ans = []
for i in range(n):
	a = input()
	ans.append(a)
b = sorted(ans, key=len)
c = 0
for i in range(0, len(b) - 1):
	if b[i] in b[i + 1]:
		c += 1
if c == len(b) - 1:
	print('YES')
	for i in range(len(b)):
		print(b[i])
else:
	print('NO')


n = int(input())
words = list()
for i in range(n):
	t = input()
	words.append(t)
words.sort(key=len)
itsin = 1
for i in range(n - 1):
	if not words[i] in words[i + 1]:
		itsin = 0
		break
if itsin:
	print('YES')
	for i in range(n):
		print(words[i])
else:
	print('NO')


l = []
z = input
for i in range(int(z())):
	l1 = z()
	l.append([len(l1), l1])
l = sorted(l)
x = l[0][1]
c = 0
d = 1
for i in sorted(l):
	if x in i[1]:
		c += 1
		x = i[1]
	else:
		d = 0
		break
if d == 1:
	print('YES')
	for i in l:
		print(i[1])
else:
	print('NO')


n = int(input())
l = []
l1 = []
for _ in range(n):
	s = input()
	l.append(s)
	l1.append(len(s))
l2 = sorted(l1)
l3 = []
f = 1
for i in range(n):
	j = l1.index(l2[i])
	l1[j] = 0
	l3.append(l[j])
for i in range(len(l3) - 1):
	if l3[i] in l3[i + 1]:
		continue
	else:
		f = 0
		break
if f == 0:
	print('NO')
else:
	print('YES')
	for i in range(len(l3)):
		print(l3[i])


n = int(input())
l = []
for i in range(n):
	s = str(input())
	l.append(s)
l.sort(key=lambda x: (len(x), x))
if n == 1:
	print('YES')
	print(l[0])
else:
	e = 0
	for j in range(1, len(l)):
		if l[j - 1] in l[j]:
			e = e + 1
	if e == n - 1:
		print('YES')
		for k in range(0, len(l)):
			print(l[k])
	else:
		print('NO')


n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(s)
l.sort(key=len)
j = 1
flag = 1
while j < n:
	if l[j].find(l[j - 1]) == -1:
		flag = 0
		break
	j += 1
if flag == 1:
	print('YES')
	for i in range(n):
		print(l[i])
else:
	print('NO')


n = int(input())
a = [input() for x in range(n)]
a.sort(key=len)
seti = True
if n > 1:
	for i in range(n - 1):
		if not a[i] in a[i + 1]:
			seti = False
			print('NO')
			break
	if seti:
		print('YES')
		print('\n'.join(a))
else:
	print('YES')
	print(a[0])


n = int(input())
strings = []
for _ in range(n):
	strings.append(input())
k = sorted(strings, key=len)
flag = True
for i in range(n - 1):
	if k[i] in k[i + 1]:
		pass
	else:
		flag = False
if flag == True:
	print('YES')
	for i in k:
		print(i)
else:
	print('NO')


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


def contains(s, S):
	for i in range(len(S) - len(s) + 1):
		if s == S[i:i + len(s)]:
			return True
	return False
n = int(input())
S = [input() for _ in range(n)]
nS = [S.pop()]
while S:
	cur = S.pop()
	if contains(cur, nS[0]):
		nS.insert(0, cur)
		continue
	if contains(nS[-1], cur):
		nS.append(cur)
		continue
	for i in range(len(nS) - 1):
		if contains(nS[i], cur) and contains(cur, nS[i + 1]):
			nS.insert(i + 1, cur)
			break
	else:
		print('NO')
		break
else:
	print('YES')
	print(*nS, sep='\n')


n = int(input())
l = []
ans = 'YES'
for i in range(n):
	l.append(input())
l = sorted(l, key=len)
for i in range(n - 1):
	if l[i] not in l[i + 1]:
		ans = 'NO'
		break
print(ans)
if ans == 'YES':
	for j in l:
		print(j)


n = int(input())
solution = [None] * n
for i in range(n):
	solution[i] = input()
solution = sorted(solution, key=len)
possible = True
for i in range(n - 1):
	if solution[i] not in solution[i + 1]:
		possible = False
		break
if possible:
	print('YES')
	print('\n'.join(solution))
else:
	print('NO')


def main():
	n = int(input())
	lines = []
	for _ in range(n):
		lines.append(input().strip())
	lines.sort(key=lambda s: len(s))
	for i in range(1, n):
		if lines[i - 1] not in lines[i]:
			print('NO')
			return
	print('YES')
	print('\n'.join(lines))
main()


import sys

def Len(n):
	return len(n)
n = int(input())
strings = []
for i in range(n):
	s = input()
	strings.append(s)
for i in range(len(strings)):
	for j in range(i, len(strings)):
		a = strings[i]
		b = strings[j]
		if len(a) > len(b):
			(a, b) = (b, a)
		if a not in b:
			print('NO')
			sys.exit(0)
print('YES')
strings.sort(key=Len)
for string in strings:
	print(string)


n = int(input())
li = []
for i in range(n):
	li.append(input())
li.sort(key=lambda string: len(string))
for i in range(1, len(li)):
	if li[i - 1] not in li[i]:
		print('NO')
		break
else:
	print('YES')
	for item in li:
		print(item)


n = int(input())
a = []
for i in range(n):
	a.append(input())
for i in range(n - 1):
	for j in range(i + 1, n):
		if len(a[i]) > len(a[j]):
			(a[i], a[j]) = (a[j], a[i])
k = 0
for i in range(n - 1):
	if a[i] in a[i + 1]:
		k = k
	else:
		k = k + 1
if k > 0:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(a[i])


d = []
l = 0
for i in range(int(input())):
	x = input()
	d.append(x)
d.sort(key=len)
for i in range(len(d) - 1):
	if d[i] in d[i + 1]:
		l += 1
if l + 1 != len(d):
	print('NO')
else:
	print('YES')
	for i in d:
		print(i)


n = int(input())
(arr, t) = ([], '')
for _ in range(n):
	t = input()
	arr.append(t)
for i in range(n - 1, 0, -1):
	for j in range(i):
		if arr[i] in arr[j]:
			(arr[i], arr[j]) = (arr[j], arr[i])
b = 1
for i in range(n):
	for j in range(i):
		if not arr[j] in arr[i]:
			b = 0
if b:
	print('YES')
	for i in range(n):
		print(arr[i])
else:
	print('NO')


import math
import os
import random
import re
from sys import stdin, stdout
from collections import Counter

def si():
	return str(input())

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
arr = []
for i in range(n):
	s = si()
	arr.append(s)
arr.sort()
arr.sort(key=len)
flag = True
for i in range(n - 1):
	if arr[i] not in arr[i + 1]:
		flag = False
if flag:
	print('YES')
	for i in range(n):
		print(arr[i])
else:
	print('NO')


n = int(input())
l = []
for i in range(n):
	l.append(input())
l.sort(key=lambda x: len(x))
sol = all((l[i] in l[i + 1] for i in range(n - 1)))
if sol:
	print('YES')
	print(*l, sep='\n')
else:
	print('NO')


import os, sys, math

def main():
	T = int(input())
	strs = []
	for _ in range(T):
		strs.append(input())
	strs.sort(key=lambda x: len(x))
	for i in range(T - 1):
		if strs[i + 1].find(strs[i]) == -1:
			print('NO')
			return 0
	print('YES')
	for x in strs:
		print(x)

def is_subs(x, y):
	return sum(l)

def debug(*args):
	if 'DEBUG' in os.environ:
		print(*args)
main()


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


s = [input() for _ in range(int(input()))]
s = list(sorted(s, key=lambda p: len(p)))
ans = 'YES'
for i in range(len(s) - 1):
	if s[i] in s[i + 1]:
		continue
	else:
		ans = 'NO'
		break
print(ans)
if ans == 'YES':
	for i in range(len(s)):
		print(s[i])


n = int(input())
temp = list()
for i in range(n):
	temp.append(input())
temp.sort(key=lambda s: len(s))
check = True
for i in range(len(temp) - 1):
	if temp[i + 1].rfind(temp[i]) == -1:
		check = False
if check:
	print('YES')
	print('\n'.join(temp))
else:
	print('NO')


n = int(input())
a = []
for i in range(n):
	s = input()
	a.append(s)
a.sort(key=len)
f = 0
for i in range(1, n):
	if a[i - 1] not in a[i]:
		f = 1
		break
if f == 0:
	print('YES')
	for i in range(n):
		print(a[i])
else:
	print('NO')


n = int(input())
l = []
for i in range(n):
	s = str(input())
	l.append([len(s), s])
l.sort()
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])


import sys
n = int(input())
lines = []
for i in range(0, n):
	lines.append(input())
lines.sort(key=len)
clone = lines.copy()
while len(clone) != 1:
	parent = clone[-1]
	for s in clone[:-1]:
		if parent.find(s) != -1:
			continue
		else:
			print('NO')
			sys.exit()
	del clone[-1]
else:
	print('YES')
	for i in lines:
		print(i)


def push(s, l=0, r=-1):
	if not a:
		a.insert(0, s)
		return 1
	if r == -1:
		r = len(a)
	if l >= r:
		a.insert(r, s)
		return 1
	m = (l + r) // 2
	if len(s) < len(a[m]):
		if s not in a[m]:
			return 0
		return push(s, l, m)
	elif len(s) > len(a[m]):
		if a[m] not in s:
			return 0
		return push(s, m + 1, r)
	elif s == a[m]:
		a.insert(m, s)
		return 1
	else:
		return 0
n = int(input())
a = []
for i in range(n):
	s = input()
	if not push(s):
		print('NO')
		quit()
print('YES')
print('\n'.join(a))


def main():
	count = int(input())
	strings = list()
	for _ in range(count):
		strings.append(input())
	sort(strings)

def sort(strings):
	strings.sort(key=len)
	res = True
	for i in range(len(strings) - 1):
		res = res and strings[i] in strings[i + 1]
	if res:
		print('YES')
		for x in strings:
			print(x)
	else:
		print('NO')
main()


n = int(input())
sts = []
for x in range(0, n):
	sts.append(input())
flag = True
sts.sort(key=lambda s: len(s))
for x in range(0, n - 1):
	if sts[x] not in sts[x + 1]:
		print('NO')
		flag = False
		break
if flag:
	print('YES')
	for x in sts:
		print(x)


n = int(input())
a = []
for i in range(n):
	s = input()
	a.append(s)
b = []
for _ in range(1, 101):
	for l in range(n):
		if len(a[l]) == _:
			b.append(a[l])
flag = 0
for j in range(n):
	for k in range(j + 1, n):
		if b[k].count(b[j]) == 0:
			print('NO')
			flag = 1
			break
	if flag == 1:
		break
	if j == n - 1:
		print('YES')
		print(*b, sep='\n')


import functools

def comparator(x, y):
	if x in y:
		return -1
	if y in x:
		return 1
	return 0

def main():
	n = int(input())
	arr = list()
	for i in range(n):
		arr.append(input())
	arr.sort(key=functools.cmp_to_key(comparator))
	for i in range(n):
		idx = i + 1
		while idx < n:
			if arr[i] not in arr[idx]:
				print('NO')
				exit(0)
			idx += 1
	print('YES')
	print('\n'.join(arr))
main()


n = int(input())
a = []
flag = 0
for i in range(n):
	s = input()
	a.append((s, len(s)))
a.sort(key=lambda a: a[1])
for i in range(1, len(a)):
	if a[i - 1][0] not in a[i][0]:
		flag = 1
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in range(len(a)):
		print(a[i][0])


n = int(input())
list1 = []
for i in range(n):
	s = input()
	list1.append(s)
for i in range(n - 1):
	for j in range(i, n):
		if len(list1[i]) > len(list1[j]):
			(list1[i], list1[j]) = (list1[j], list1[i])
f = 0
for i in range(n - 1):
	x = list1[i + 1].find(list1[i])
	if x >= 0:
		continue
	else:
		f = 1
if f == 0:
	print('YES')
	for i in range(n):
		print(list1[i])
else:
	print('NO')


n = int(input())
w = []
for i in range(n):
	w.append(input())
w.sort()
w.sort(key=len)
h = 1
for i in range(n - 2, -1, -1):
	if len(w[i + 1].split(w[i])) < 2:
		h = 0
		break
if h:
	print('YES')
	print('\n'.join(w))
else:
	print('NO')


n = int(input())
a = []
l = []
for i in range(n):
	a.append(input())
for i in range(n):
	l.append(len(a[i]))
(l, a) = zip(*sorted(zip(l, a)))
(l, a) = (list(t) for t in zip(*sorted(zip(l, a))))
c = 0
for i in range(1, n):
	if l[i - 1] < l[i]:
		if a[i - 1] in a[i]:
			c += 1
	if l[i - 1] == l[i]:
		if a[i - 1] == a[i]:
			c += 1
if c == n - 1:
	print('YES')
	for elem in a:
		print(elem)
else:
	print('NO')


def sort(s, n):
	for i in range(1, n):
		temp = s[i]
		j = i - 1
		while j >= 0 and len(temp) < len(s[j]):
			s[j + 1] = s[j]
			j -= 1
		s[j + 1] = temp
n = int(input())
strings = []
for _ in range(n):
	s = input()
	strings.append(s)
check = True
sort(strings, n)
for i in range(0, n - 1):
	if strings[i] not in strings[i + 1]:
		check = False
		break
if not check:
	print('NO')
else:
	print('YES')
	for i in strings:
		print(i)


l = []
for i in range(int(input())):
	l.append(input())
l = sorted(l, key=len)
for i in range(len(l)):
	for f in range(i, len(l)):
		if l[i] not in l[f]:
			print('NO')
			exit()
else:
	print('YES')
	for elem in l:
		print(elem)


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))


def inline():
	return [int(e) for e in input().split()]

def inlines(n):
	return [input() for i in range(n)]

def outline(l):
	for e in l:
		print(e, end=' ')
	print()

def outlist(l):
	for e in l:
		print(e)

def length(s):
	return len(s)
n = int(input())
l = inlines(n)
ans = True
l.sort(key=length)
for i in range(1, n):
	if l[i - 1] not in l[i]:
		ans = False
if ans:
	print('YES')
	outlist(l)
else:
	print('NO')


def main():
	n = int(input())
	arr = [input() for t in range(n)]
	arr = sorted(arr, key=lambda x: len(x))
	for i in range(len(arr) - 1):
		if arr[i] not in arr[i + 1]:
			print('NO')
			return
	print('YES')
	print('\n'.join(arr))
main()


import sys

def main():
	N = int(input())
	S = sys.stdin.read().splitlines()
	S.sort(key=lambda x: len(x))
	for i in range(N - 1):
		if S[i] not in S[i + 1]:
			print('NO')
			break
	else:
		print('YES')
		print(*S, sep='\n')
main()


n = int(input())
list1 = []
for _ in range(n):
	strings = input()
	list1.append(strings)
solist = sorted(list1, key=lambda x: len(x))
flag = 1
for i in range(1, len(solist)):
	if solist[i - 1] not in solist[i]:
		flag = 0
		break
if flag == 0:
	print('NO')
else:
	print('YES')
	for i in solist:
		print(i)


import functools

def isSub(a, b):
	if a in b:
		return -1
	elif a == b:
		return 0
	else:
		return 1

def cmp(a, b):
	return isSub(a, b)

def check(s):
	for i in range(1, len(s)):
		if not isSub(s[i - 1], s[i]) == -1:
			return False
	return True
n = int(input())
a = [input() for i in range(n)]
s = sorted(a, key=functools.cmp_to_key(cmp))
if check(s):
	print('YES')
	for item in s:
		print(item)
else:
	print('NO')


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()


def fun(a, b):
	if a in b:
		return True
	return False
n = int(input())
l = []
for i in range(n):
	l.append(input())
R = []
L = sorted(l, key=len)
S = True
for i in range(len(L)):
	for j in L[i:]:
		if not fun(L[i], j):
			S = False
			break
	if S:
		R.append(L[i])
	else:
		break
if len(R) < n:
	print('NO')
else:
	print('YES')
	for i in R:
		print(i, end='\n')


n = int(input())
a = [str(input()) for i in range(0, n)]
a = sorted(a, key=lambda x: len(x))
s = 0
for i in range(0, n - 1):
	if a[i] in a[i + 1]:
		s = s + 1
if s == n - 1:
	print('YES')
	for i in a:
		print(i)
else:
	print('NO')


def subset(A, B, l_A, l_B):
	for i in range(l_B - l_A + 1):
		X = B[i:l_A + i]
		if A == X:
			return False
	return True

def main():
	n = int(input())
	X = ['' for _ in range(n)]
	for i in range(n):
		x = input()
		X[i] = (len(x), x)
	X.sort()
	for i in range(n - 1):
		if subset(X[i][1], X[i + 1][1], X[i][0], X[i + 1][0]):
			print('NO')
			return
	print('YES')
	for i in range(n):
		print(X[i][1])
main()


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())
a = []
for i in range(n):
	a.append(input())
a = sorted(a, key=lambda x: len(x))
flag = True
for i in range(len(a) - 1):
	if a[i + 1].find(a[i]) < 0:
		flag = False
		break
if flag:
	print('YES')
	for x in a:
		print(x)
else:
	print('NO')


n = int(input())
a = []
for i in range(n):
	a.append(input())
res = []
all_ok = True
res.append(a[0])
for i in range(1, n):
	s1 = a[i]
	added = False
	for j in range(len(res)):
		s2 = res[j]
		ind1 = s1.find(s2)
		ind2 = s2.find(s1)
		if ind1 == -1 and ind2 == -1:
			all_ok = False
			break
		if ind1 == -1:
			res.insert(j, s1)
			added = True
			break
	if not all_ok:
		break
	if not added:
		res.insert(len(res) + 1, s1)
if not all_ok:
	print('NO')
else:
	print('YES')
	for i in range(len(res)):
		print(res[i])


n = int(input())
l = []
for i in range(n):
	s = input()
	l.append((len(s), s))
poss = 1
l.sort()
for i in range(1, n):
	done = 0
	for j in range(l[i][0] - l[i - 1][0] + 1):
		if l[i][1][j:j + l[i - 1][0]] == l[i - 1][1]:
			done = 1
			break
	if done == 0:
		poss = 0
		break
if poss:
	print('YES')
	for i in l:
		print(i[1])
else:
	print('NO')


def fun(a):
	return len(a)
n = int(input())
l = []
for _ in range(n):
	s = input()
	l.append(s)
l.sort(key=fun)
c = 1
for i in range(len(l) - 1):
	if l[i] in l[i + 1]:
		c += 1
if c == n:
	print('YES')
	for i in l:
		print(i)
else:
	print('NO')


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)


lenstr = [0] * 101
for i in range(101):
	lenstr[i] = []
n = int(input())
for i in range(n):
	a = input()
	lenstr[len(a)].append(a)
for i in range(101):
	lenstr[i].sort()
flag = 0
k = -1
for i in range(101):
	for j in range(len(lenstr[i])):
		if k == -1:
			k = lenstr[i][j]
		if k != -1:
			if lenstr[i][j].find(k) == -1:
				flag = 1
				print('NO')
				break
			k = lenstr[i][j]
	if flag == 1:
		break
if flag == 0:
	print('YES')
	for i in range(101):
		for j in range(len(lenstr[i])):
			print(lenstr[i][j])
	print()


n = int(input())
arr = []
for i in range(n):
	st = input()
	arr.append(st)
chck = 0
arr = sorted(arr, key=len)
for i in range(len(arr) - 1):
	if arr[i] in arr[i + 1]:
		continue
	else:
		print('NO')
		chck = 1
		break
if chck == 0:
	print('YES')
	for item in arr:
		print(item)


t = int(input())
s = []
for _ in range(t):
	s.append(input())
for _ in range(t):
	for i in range(1, t):
		if s[i - 1] in s[i]:
			pass
		elif s[i] in s[i - 1]:
			(s[i], s[i - 1]) = (s[i - 1], s[i])
		else:
			print('NO')
			exit()
print('YES')
print('\n'.join(s))


n = int(input())
si_ls = []
for i in range(n):
	si = str(input())
	si_ls.append(si)
si_ls = sorted(si_ls, key=lambda s: len(s))
fl = 0
for i in range(len(si_ls) - 1):
	if si_ls[i] not in si_ls[i + 1]:
		fl = 1
		break
	else:
		continue
if fl == 0:
	print('YES')
	for i in si_ls:
		print(i)
else:
	print('NO')


import sys

def inint():
	return int(input())

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

def main():
	n = inint()
	arr = [input() for i in range(n)]
	arr.sort(key=lambda el: len(el))
	ok = all((arr[i] in arr[i + 1] for i in range(n - 1)))
	if ok:
		print('YES' + '\n' + '\n'.join(arr))
	else:
		print('NO')
main()


n = int(input())
s = ['' for i in range(n)]
l = [0 for i in range(n)]
for i in range(n):
	s[i] = input()
	l[i] = len(s[i])
for i in range(n):
	for j in range(n - i - 1):
		if l[j] > l[j + 1]:
			(l[j], l[j + 1]) = (l[j + 1], l[j])
			(s[j], s[j + 1]) = (s[j + 1], s[j])
f = True
for i in range(n - 1):
	if s[i + 1].rfind(s[i]) == -1:
		f = False
		break
if not f:
	print('NO')
else:
	print('YES')
	for i in s:
		print(i)


n = int(input())
strs = []
for i in range(n):
	strs.append(input())
strs.sort(key=lambda x: len(x))
flag = 'YES'
for i in range(1, n):
	if not strs[i - 1] in strs[i]:
		flag = 'NO'
		break
print(flag)
if flag == 'YES':
	for i in strs:
		print(i)


def solve(a):
	for i in range(len(a) - 1):
		if a[i] not in a[i + 1]:
			return ['NO']
	return ['YES', a]
n = int(input())
a = [input() for i in range(n)]
a.sort(key=lambda x: len(x))
res = solve(a)
if len(res) == 1:
	print(res[0])
else:
	print(res[0])
	print('\n'.join(res[1]))


n = int(input())
a = []
for i in range(n):
	a.append(input())
a.sort(key=len, reverse=True)
arr1 = []
i = 0
while True:
	if i >= len(a):
		break
	if i == 0:
		arr1.append(a[0])
	elif a[i] in arr1[len(arr1) - 1]:
		arr1.append(a[i])
	i += 1
arr1.reverse()
if len(arr1) == n:
	print('YES')
	for i in arr1:
		print(i)
else:
	print('NO')


from functools import cmp_to_key

def cmp(s1, s2):
	if s1 in s2:
		return -1
	if s2 in s1:
		return 1
	return 0

def main():
	n = int(input())
	a = []
	for i in range(n):
		a.append(input())
	a = sorted(a, key=cmp_to_key(cmp))
	for i in range(n - 1):
		if a[i] not in a[i + 1]:
			print('NO')
			return
	print('YES')
	for i in range(n):
		print(a[i])
main()


n = int(input())
k = []
f = 0
for i in range(n):
	k.append(input())
for i in range(n):
	for j in range(0, n - i - 1):
		if len(k[j]) > len(k[j + 1]):
			(k[j], k[j + 1]) = (k[j + 1], k[j])
for i in range(len(k) - 1):
	if k[i] not in k[i + 1]:
		f = 1
		break
if f == 1:
	print('NO')
else:
	print('YES')
	print('\n'.join(k))


n = int(input())
s = []
for i in range(n):
	s.append(input())
dp = [[0, 'NONE'] for i in range(n)]
for i in range(n):
	dp[i][1] = s[i]
for i in range(n):
	for j in range(n):
		if s[i] in s[j]:
			dp[i][0] += 1
dp.sort()
dp.reverse()
x = n
t = True
for i in range(n):
	if dp[i][0] < x:
		t = False
		break
	x -= 1
if t:
	print('YES')
	for i in range(n):
		print(dp[i][1])
else:
	print('NO')


n = int(input())
a = []
for _ in range(n):
	a.append(input())
b = sorted(a, key=len, reverse=True)
for i in range(n - 1):
	if b[i + 1] not in b[i]:
		print('NO')
		quit()
print('YES')
for i in range(n):
	print(b[n - 1 - i])


t = int(input())
l = []
for _ in range(t):
	l.append(input())
l.sort(key=lambda s: len(s))
count = 0
for i in range(1, t):
	if l[i - 1] in l[i]:
		count += 1
if count == t - 1:
	print('YES')
	for i in range(t):
		print(l[i])
else:
	print('NO')


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')


def solve():
	n = int(input().strip())
	a = []
	done = True
	for _ in range(n):
		a.append(input().strip())
	b = sorted(a, key=len)
	for i in range(n - 1):
		if b[i + 1].find(b[i]) == -1:
			done = False
			break
	if done:
		return ('YES', b)
	else:
		return ('NO', None)
(y, b) = solve()
print(y)
if b is not None:
	for i in b:
		print(i)


def f(l, n):
	h = 0
	for i in range(n - 1):
		a = l[i]
		b = len(a)
		c = len(l[i + 1])
		for j in range(c - b + 1):
			if a == l[i + 1][j:j + b]:
				h += 1
				break
			j += 1
	if h == n - 1:
		return 1
	return 0
n = int(input())
a = []
for i in range(n):
	a.append(input())
b = sorted(a, key=len)
k = f(b, n)
if k == 1:
	print('YES')
	for i in b:
		print(i)
else:
	print('NO')


n = int(input())
a = []
flag = 0
for i in range(n):
	a += [input()]
a.sort(key=lambda x: len(x))
for i in range(n - 1):
	if a[i] not in a[i + 1]:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(a[i])


n = int(input())
s = []
for _ in range(n):
	t = list(input())
	s.append([len(t), t])
s.sort()
f = 1
for i in range(n - 1):
	(a, b) = (s[i][1], s[i + 1][1])
	ok = 0
	for j in range(s[i + 1][0] - s[i][0] + 1):
		cnt = 0
		for k in range(s[i][0]):
			if a[k] == b[j + k]:
				cnt += 1
		if cnt == s[i][0]:
			ok = 1
		if ok:
			break
	if not ok:
		f = 0
		break
print('YES' if f else 'NO')
if f:
	for i in range(n):
		ans = ''.join(s[i][1])
		print(ans)


def lSort(str):
	return len(str)
n = int(input())
arr = []
done = True
for i in range(n):
	arr.append(input())
arr.sort(key=lSort, reverse=False)
for i in range(n - 1):
	if not arr[i] in arr[i + 1]:
		done = False
		break
if done:
	print('YES')
	print('\n'.join((x for x in arr)))
else:
	print('NO')


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


n = int(input())
a = [input() for i in range(n)]
used = [False] * n
res = []
for i in range(n):
	for j in range(n):
		if used[j]:
			continue
		for k in range(n):
			if used[k] or k == j:
				continue
			if a[k] not in a[j]:
				break
		else:
			res.append(a[j])
			used[j] = True
			break
	else:
		print('NO')
		exit()
print('YES')
res = res[::-1]
print('\n'.join(res))


li = []
for _ in range(int(input())):
	s = input()
	li.append(s)
lst2 = sorted(li, key=len)
c = 1
for i in range(len(lst2) - 1):
	if lst2[i] not in lst2[i + 1]:
		c = 0
if c == 1:
	print('YES')
	for j in lst2:
		print(j)
else:
	print('NO')


n = int(input())
a = []
for i in range(n):
	a.append(input())
a.sort(key=lambda x: len(x))
if all((m in n for (m, n) in zip(a, a[1:]))):
	print('YES')
	for i in range(n):
		print(a[i])
else:
	print('NO')


n = int(input())
x = []
for i in range(0, n):
	x.append(input())
flag = 1
for i in range(0, n):
	for j in range(i + 1, n):
		if len(x[i]) >= len(x[j]) and x[j] not in x[i]:
			flag = 0
			break
		elif len(x[i]) >= len(x[j]) and x[j] in x[i]:
			temp = x[i]
			x[i] = x[j]
			x[j] = temp
		elif len(x[i]) <= len(x[j]) and x[i] not in x[j]:
			flag = 0
			break
if flag == 1:
	print('YES')
	for i in x:
		print(i)
else:
	print('NO')


n = int(input())
st = []
lens = []
for _ in range(n):
	new = input()
	st.append(new)
	lens.append((len(new), _))
lens = sorted(lens)
stnew = []
for i in range(n):
	stnew.append(st[lens[i][1]])
for i in range(1, n):
	if stnew[i - 1] not in stnew[i]:
		print('NO')
		exit(0)
print('YES')
for t in stnew:
	print(t)


ll = lambda : map(int, input().split())
t = lambda : int(input())
ss = lambda : input()
lx = lambda x: map(int, input().split(x))
yy = lambda : print('YES')
nn = lambda : print('NO')
from math import log10, log2, ceil, factorial as fac, gcd, inf, sqrt, log
from bisect import bisect_right as br, bisect_left as bl
from collections import Counter
mod = 10 ** 9 + 7

def f():
	n = t()
	l = {}
	d = []
	for i in range(n):
		q = ss()
		if len(q) not in l:
			l[len(q)] = []
		l[len(q)].append(q)
	last = 1
	fl = 0
	x = 0
	for i in sorted(l):
		if last == 1:
			last = l[i][0]
			fl = 1
		else:
			fl = 0
		for j in range(fl, len(l[i])):
			if last not in l[i][j]:
				x = 1
				break
			last = l[i][j]
		if x:
			nn()
			break
	else:
		yy()
		for i in sorted(l):
			for j in l[i]:
				print(j)
f()


n = int(input())
L = []
for i in range(n):
	L.append(input())
L = sorted(L, key=len)
for i in range(0, n - 1):
	if L[i] not in L[i + 1]:
		print('NO')
		quit()
print('YES')
for i in range(n):
	print(L[i])


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


number = int(input())
a = []
m = True
answer = 'YES'

def locate(palabra, num):
	if num > len(a):
		pass
	elif num == 1:
		temp = a[-num]
		a[-num] = palabra
		a.append(temp)
		locate(palabra, 3)
	elif palabra in a[-num]:
		temp = a[-num]
		a[-num] = palabra
		a[-num + 1] = temp
		locate(palabra, num + 1)
	elif a[-num] not in palabra:
		global answer
		answer = 'NO'
		global m
		m = False
for i in range(number):
	pala = input()
	if len(a) == 0:
		a.append(pala)
	elif m == False:
		answer = 'NO'
	elif a[-1] in pala:
		a.append(pala)
	elif pala in a[-1]:
		locate(pala, 1)
	else:
		answer = 'NO'
		m = False
if answer == 'NO':
	print(answer)
else:
	print(answer)
	for i in a:
		print(i)


(n, l) = (int(input()), [])
for i in range(n):
	l.append(input())
m = max(l, key=lambda x: len(x))
l = sorted(l, key=lambda x: len(x))
for i in range(n - 1):
	if l[i] not in l[i + 1]:
		print('NO')
		exit()
print('YES')
print(*l, sep='\n')


N = int(input())
strs = [input() for _ in range(N)]
strs.sort(key=len)
ok = True
for i in range(N - 1):
	if strs[i] not in strs[i + 1]:
		ok = False
		break
if ok:
	print('YES')
	for s in strs:
		print(s)
else:
	print('NO')


def f(a):
	for (i, si) in enumerate(a):
		for (j, sj) in enumerate(a):
			if sj not in si:
				break
		else:
			return (i, si)
	return (None, None)
n = int(input())
s = []
for i in range(n):
	s.append(input().strip())
res = []
while s:
	(i, si) = f(s)
	if i == None:
		break
	res.append(si)
	del s[i]
if len(res) != n:
	print('NO')
else:
	print('YES')
	for s in res[::-1]:
		print(s)


n = int(input())
l = []
for _ in range(n):
	s = input()
	l.append(s)
l.sort(key=len)
m = 0
for i in range(n):
	c = 0
	for j in range(0, i):
		if l[j] in l[i]:
			c += 1
	if c == i:
		m += 1
if m == n:
	print('YES')
	for i in l:
		print(i)
else:
	print('NO')


from sys import stdin, stdout
import bisect

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	n = inp()
	l = []
	mi = -1100
	for i in range(n):
		s = input()
		l.append(s)
		if len(s) > mi:
			mi = len(s)
			z = s
	l.sort(key=len)
	c = 0
	for i in range(n - 1):
		if l[i] not in l[i + 1]:
			c = 1
			break
	if c == 0:
		pr('YES')
		for i in l:
			pr(i)
	else:
		pr('NO')
solve()


a = int(input())
b = []
for _ in range(a):
	b += [input()]
b.sort(key=len)
for i in range(a - 1):
	if b[i] in b[i + 1]:
		skip = 1
	else:
		print('NO\n')
		exit()
print('YES')
for i in b:
	print(i)


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])


def sort(arr):
	return sorted(arr, key=len)

def check_substrings(arr, n):
	for x in range(0, n - 1):
		if arr[x] not in arr[x + 1]:
			return 'NO'
	return 'YES'

def main():
	n = int(input())
	arr = [input() for x in range(0, n)]
	arr = sort(arr)
	ans = check_substrings(arr, n)
	if ans == 'YES':
		print('YES')
		print(*arr, sep='\n')
	else:
		print('NO')
main()


import os
import io
import sys
from collections import Counter, defaultdict
import math
import random
import heapq as hq
from functools import reduce, cmp_to_key
from collections import deque
import threading
import bisect

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def compare(a, b):
	la = len(a)
	lb = len(b)
	if la > lb:
		return 1
	elif lb > la:
		return -1
	return a == b

def check(a, b):
	l = len(b)
	for i in range(l):
		for j in range(i + 1, l + 1):
			if b[i:j] == a:
				return True
	return False
n = iinput()
strings = []
for i in range(n):
	strings.append(input())
strings.sort(key=cmp_to_key(compare))
flag = True
for i in range(n - 1):
	if not check(strings[i], strings[i + 1]):
		flag = False
		break
if flag:
	print('YES')
	for i in strings:
		print(i)
else:
	print('NO')


numwords = int(input())
words = []
for k in range(numwords):
	words.append(input())
state = True
words = sorted(words, key=len)
for index in range(numwords - 1):
	if words[index] not in words[index + 1]:
		state = False
if state == False:
	print('NO')
else:
	print('YES')
	for word in words:
		print(word)


n = int(input())
ss = []
for i in range(n):
	s = input()
	flag = False
	for j in range(i):
		if ss[j] in s:
			continue
		elif s in ss[j]:
			ss.insert(j, s)
			flag = True
			break
		else:
			print('NO')
			exit()
	if flag == False:
		ss.append(s)
print('YES')
for s in ss:
	print(s)


strs = []
strlen = []
temp = []
n = input()
for i in range(0, int(n)):
	s = input()
	strs.append(s)
	strlen.append(len(s))
for i in range(0, int(n)):
	x = strlen.index(min(strlen))
	temp.append(strs[x])
	strlen.remove(min(strlen))
	strs.remove(strs[x])
flag = 0
for i in range(0, int(n) - 1):
	if temp[i] not in temp[i + 1]:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in temp:
		print(i)


n = int(input())
strgs = [input() for _ in range(n)]
strgs.sort(key=len)
possible = True
for i in range(n - 1):
	possible &= strgs[i] in strgs[i + 1]
if possible:
	print('YES')
	for s in strgs:
		print(s)
else:
	print('NO')


n = int(input())
st = []
for _ in range(n):
	st.append(input())
check = True
i_n = 0
for _ in range(n):
	for s in range(i_n, n - 1):
		if st[s] not in st[s + 1]:
			if st[s + 1] in st[s]:
				(st[s], st[s + 1]) = (st[s + 1], st[s])
				i_n = 0
			else:
				check = False
				break
	if not check:
		break
if not check:
	print('NO')
else:
	print('YES')
	for i in st:
		print(i)


def bsort(arr):
	n = len(arr)
	for i in range(n):
		for j in range(0, n - i - 1):
			if arr[j][1] > arr[j + 1][1]:
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])

def contains(s, sub):
	if sub in s:
		return True
	else:
		return False

def valid(arr):
	for i in range(len(arr) - 1):
		if contains(arr[i + 1], arr[i]):
			continue
		else:
			return False
	return True

def printarr(arr):
	for i in arr:
		print(i)
n = int(input())
l = []
for _ in range(n):
	s = input()
	l.append([s, len(s)])
bsort(l)
fin = []
for i in l:
	fin.append(i[0])
if valid(fin):
	print('YES')
	printarr(fin)
else:
	print('NO')


n = int(input())
s = []
for i in range(n):
	s.append(input())
s = sorted(s, key=len)
case = True
for i in range(n - 1):
	if s[i] not in s[i + 1]:
		case = False
		break
if case:
	print('YES')
	for i in s:
		print(i)
else:
	print('NO')


def print_arr(arr):
	print(*arr, sep='\n')
n = int(input())
s = [input() for x in range(n)]
s.sort(key=lambda x: len(x))
for i in range(1, n):
	if s[i - 1] not in s[i]:
		exit(print('NO'))
print('YES')
print_arr(s)


def cmp(s1):
	return len(s1)
n = int(input())
a = []
for i in range(n):
	s = input()
	a.append(s)
a.sort(key=cmp)
i = 1
ok = True
while i < n:
	if a[i - 1] not in a[i]:
		ok = False
		break
	i += 1
if ok:
	print('YES')
	for i in a:
		print(i)
else:
	print('NO')


n = int(input())
a = []
for i in range(n):
	a.append(input().strip())
a = sorted(a, key=lambda s: len(s))
for i in range(n - 1):
	if a[i] in a[i + 1]:
		continue
	else:
		print('NO')
		exit()
print('YES')
for i in a:
	print(i)


n = int(input())
s = []
for i in range(n):
	s.append(input())
s.sort(key=len)
for i in range(1, n):
	if not s[i - 1] in s[i]:
		print('NO')
		exit()
print('YES')
print('\n'.join(s))


n = int(input())
M = []
for i in range(n):
	M.append(input())
M.sort(key=len)
i = 0
test = True
while i <= n - 2 and test == True:
	test = M[i] in M[i + 1]
	i += 1
if test == False:
	print('NO')
else:
	print('YES')
	for k in M:
		print(k)


n = int(input())
s = []
for i in range(n):
	t = input()
	s.append([len(t), t])
s.sort()
for i in range(n):
	s[i] = s[i][1]
ans = [s[0]]
s.remove(s[0])
possible = True
for i in range(n - 1):
	possible = False
	for j in range(len(s)):
		if ans[len(ans) - 1] in s[j]:
			ans.append(s[j])
			s.remove(s[j])
			possible = True
			break
	if not possible:
		break
if not possible:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(ans[i])


def sortBy(inputStr):
	return len(inputStr)
n = int(input())
a = []
for i in range(n):
	a.append(input())
a.sort(key=sortBy)
b = True
for i in range(n - 1):
	if a[i] in a[i + 1]:
		b = True
	else:
		b = False
		break
if b:
	print('YES')
	for i in a:
		print(i)
else:
	print('NO')


n = int(input())
strings = [input().strip() for __ in range(n)]
subs = {string: set() for string in strings}
for string in strings:
	for sub in strings:
		if sub in string:
			subs[string].add(sub)
strings = sorted(strings, key=lambda string: len(subs[string]))
for i in range(n):
	for j in range(i):
		if not strings[j] in strings[i]:
			print('NO')
			exit()
print('YES')
for string in strings:
	print(string)


n = int(input())
arr1 = []
for tst in range(n):
	string = input()
	arr1.append(string)
arr1.sort(key=lambda s: len(s))
flag = 1
for i in range(n - 1):
	if arr1[i + 1].find(arr1[i]) == -1:
		flag = 0
		break
if flag:
	print('YES')
	for i in arr1:
		print(i)
else:
	print('NO')


a = int(input())
x = 0
strs = list()
ind = list()
while x < a:
	strs.append(input())
	ind.append(len(strs[x]))
	x += 1
x = 0
y = 0
while x < len(ind) - 1:
	if ind[x] > ind[x + 1]:
		temp = ind[x + 1]
		ind[x + 1] = ind[x]
		ind[x] = temp
		temp = strs[x + 1]
		strs[x + 1] = strs[x]
		strs[x] = temp
		y = x
		while y > 0:
			if ind[y] < ind[y - 1]:
				temp = ind[y - 1]
				ind[y - 1] = ind[y]
				ind[y] = temp
				temp = strs[y - 1]
				strs[y - 1] = strs[y]
				strs[y] = temp
				y -= 1
			else:
				y = 0
	x += 1
x = len(strs) - 1
y = 0
while y < x:
	if not strs[x - y - 1] in strs[x - y]:
		print('NO')
		break
	y += 1
else:
	print('YES')
	for x in strs:
		print(x)


def Len(s):
	return len(s)
n = int(input())
s = []
for i in range(n):
	s.append(input())
s.sort(key=Len)
for i in range(1, n):
	if s[i].find(s[i - 1]) == -1:
		print('NO')
		exit(0)
print('YES')
for i in s:
	print(i)


n = int(input())
l = [input() for _ in range(n)]
l.sort(key=lambda x: len(x))
ok = True
for i in range(n - 1):
	if l[i] not in l[i + 1]:
		ok = False
		break
if ok:
	print('YES')
	print(*l, sep='\n')
else:
	print('NO')


lis = []
for _ in range(int(input())):
	lis.append(input())
lis = sorted(lis, key=len)
for i in range(len(lis) - 1):
	if lis[i] not in lis[i + 1]:
		print('NO')
		exit(0)
print('YES')
for i in lis:
	print(i)


n = int(input())
st = []
for i in range(n):
	word = input()
	st.append(word)
st = sorted(st, key=len)
f = 0
preword = st[0]
for i in range(1, n):
	if len(st[i]) == len(st[i - 1]):
		if st[i] != st[i - 1]:
			f = 1
	elif st[i].find(st[i - 1]) == -1:
		f = 1
	if f == 1:
		break
if f == 1:
	print('NO')
else:
	print('YES')
	for i in st:
		print(i)


def lenght(x):
	return len(x)
n = int(input())
mas = []
for i in range(n):
	mas.append(input())
mas.sort(key=lenght)
for i in range(n - 1):
	if not mas[i] in mas[i + 1]:
		print('NO')
		exit()
print('YES')
print('\n'.join(mas))


n = int(input())
m = []
while n != 0:
	s = input()
	m.append(s)
	n -= 1
n = 1
while n < len(m):
	for i in range(len(m) - n):
		if len(m[i]) > len(m[i + 1]):
			(m[i], m[i + 1]) = (m[i + 1], m[i])
	n += 1
ok = True
for i in range(len(m) - 1):
	if not m[i] in m[i + 1]:
		ok = False
if ok:
	print('YES')
	for elem in m:
		print(elem)
else:
	print('NO')


n = int(input())
li = []
result = True
flag = False
for i in range(0, n):
	a = input()
	li.append(a)
li.sort(key=lambda x: len(x))
for i in range(0, n - 1):
	result = li[i + 1].find(li[i]) != -1
	if not result:
		flag = True
		break
	else:
		flag = False
if flag:
	print('NO')
else:
	print('YES')
	for i in range(0, n):
		print(li[i])


a = int(input())
b = [input() for x in range(a)]
b.sort(key=len)
for x in range(len(b)):
	try:
		if b[x] in b[x + 1]:
			continue
		print('NO')
		break
	except:
		print('YES')
		for x in b:
			print(x)


n = int(input())
lst = []
for i in range(n):
	j = input()
	lst.append(j)
l2 = sorted(lst, key=len)
f = 0
for i in range(1, n):
	if l2[i - 1] in l2[i]:
		continue
	else:
		f = 1
		break
if f == 1:
	print('NO')
else:
	print('YES')
	for j in range(n):
		print(l2[j])


def isSubstring(s, sub):
	if s.find(sub) == -1:
		return False
	else:
		return True

def solve(A, N):
	for i in range(0, len(A) - 1):
		if isSubstring(A[i + 1], A[i]):
			pass
		else:
			print('NO')
			return
	print('YES')
	for i in A:
		print(i)
	return
n = int(input())
A = []
for i in range(n):
	A.append(str(input()))
solve(sorted(A, key=len), n)


n = int(input())
l = []
for i in range(n):
	l.append(input())
for i in range(n):
	for j in range(n - 1):
		if l[j + 1] in l[j]:
			k = l[j]
			l[j] = l[j + 1]
			l[j + 1] = k
ans = 'YES'
for i in range(1, n):
	if not l[i - 1] in l[i]:
		ans = 'NO'
print(ans)
if ans == 'YES':
	for i in l:
		print(i)


import sys
import math
import itertools
import collections

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return '\n'.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber
n = ii()
sarr = [input() for i in range(n)]
for i in range(n):
	for j in range(i + 1, n):
		if sarr[i].find(sarr[j]) != -1:
			(sarr[i], sarr[j]) = (sarr[j], sarr[i])
for i in range(n - 1):
	if sarr[i + 1].find(sarr[i]) == -1:
		exit(print('NO'))
print('YES')
print(wr(sarr))


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac
from itertools import permutations as permu

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
num = int(z())
lst = []
for _ in range(num):
	t = z()
	lst.append((len(t), t))
lst = sorted(lst)
ans = 'YES'
for i in range(num - 1):
	if lst[i][1] in lst[i + 1][1]:
		continue
	ans = 'NO'
	break
if ans == 'YES':
	print(ans)
	for i in lst:
		print(i[1])
else:
	print('NO')


n = int(input())
s = []
for i in range(n):
	st = input()
	s.append((len(st), st))
s.sort()
flag = 1
for i in range(n - 1):
	(index, val) = s[i]
	if val in s[i + 1][1]:
		flag = 1
	else:
		flag = 0
		break
if flag == 0:
	print('NO')
	exit(0)
else:
	print('YES')
	for i in range(n):
		(index, val) = s[i]
		print(val)


n = int(input())
a = [input() for i in range(n)]
res = True
for i in range(n):
	for j in range(n - 1 - i):
		if a[j + 1] in a[j]:
			(a[j], a[j + 1]) = (a[j + 1], a[j])
		elif a[j] not in a[j + 1]:
			res = False
			break
	if not res:
		break
if not res:
	print('NO')
else:
	print('YES')
	print('\n'.join(a))


n = int(input())
(di, mas) = ({}, [])
for i in range(n):
	q = input()
	a = len(q)
	if di.get(a) == None:
		di[a] = set()
	mas.append(a)
	di[a].add(q)
e = 0
res = ''
mas.sort()
from sys import exit
for (i, p) in enumerate(mas):
	x = di[p]
	if len(x) != 1:
		print('NO')
		exit()
	for (j, z) in enumerate(x):
		ads = z
	if e == 1:
		if y not in ads:
			print('NO')
			exit()
	y = ads
	res += y
	res += '\n'
	e = 1
print('YES')
print(res)


n = int(input())
L = sorted([input() for k in range(n)], key=lambda palabra: len(palabra))
res = 'YES'
for k in range(n - 1):
	if not L[k] in L[k + 1]:
		res = 'NO'
		break
print(res)
if res == 'YES':
	print('\n'.join(L))


n = int(input())
s = []
for i in range(0, n):
	s.append(input())
a = []
for i in range(0, n):
	a.append([len(s[i]), s[i]])
a.sort()
flag = True
for i in range(1, n):
	if not a[i - 1][1] in a[i][1]:
		flag = False
		break
if flag:
	print('YES')
	for i in a:
		print(i[1])
else:
	print('NO')


from sys import exit
n = int(input())
strings = [input() for _ in range(n)]
strings = sorted(strings, key=len)
for i in range(len(strings) - 1):
	if strings[i] not in strings[i + 1]:
		print('NO')
		exit()
print('YES')
for string in strings:
	print(string)


n = int(input())
arr = []
for i in range(n):
	arr.append(str(input()))
arr.sort(key=lambda x: len(x))
flag = True
for i in range(n - 1):
	if arr[i] not in arr[i + 1]:
		flag = False
if flag:
	print('YES')
	for i in range(n):
		print(arr[i])
else:
	print('NO')


n = int(input())
X = []
S = []
for i in range(n):
	s = str(input())
	X.append((len(s), s))
	S.append(s)
X.sort()
ans = []
for (_, s) in X:
	temp = set()
	for l in range(len(s)):
		for r in range(len(s)):
			temp.add(s[l:r + 1])
	for t in ans:
		if t not in temp:
			print('NO')
			exit()
	else:
		ans.append(s)
print('YES')
print(*ans, sep='\n')


n = int(input())
strs = []
for k in range(n):
	temp = input()
	strs.append((len(temp), temp))
strs.sort()
for k in range(n - 1):
	if strs[k][1] not in strs[k + 1][1]:
		print('NO')
		exit()
print('YES')
for e in strs:
	print(e[1])


import sys
import math
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
n = int(input())
s = list()
for i in range(n):
	s.append(str(input()))
s.sort(key=len)
flag = 1
for i in range(n - 1):
	if s[i] not in s[i + 1]:
		flag = 0
		break
if flag:
	print('YES')
	for i in range(n):
		print(s[i])
else:
	print('NO')


n = int(input())
s = []
for _ in range(n):
	s.append(input())
s = sorted(s, key=len)
flag = 1
for i in range(1, n):
	if s[i - 1] not in s[i]:
		flag = 0
if flag == 1:
	print('YES')
	for item in s:
		print(item)
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())
l = []
for i in range(n):
	l.append(input())
l1 = sorted(l, key=len)
for j in range(len(l1) - 1):
	if l1[j] not in l1[j + 1]:
		print('NO')
		break
else:
	print('YES')
	for k in l1:
		print(k)


def isSubstring(s1, s2):
	M = len(s1)
	N = len(s2)
	for i in range(N - M + 1):
		flag = True
		for j in range(M):
			if s2[i + j] != s1[j]:
				flag = False
		if flag:
			return i
	return -1
n = int(input())
s = []
for i in range(n):
	a = str(input())
	s.append([len(a), a])
s.sort()
flag = True
for i in range(n - 1):
	if isSubstring(s[i][1], s[i + 1][1]) == -1:
		flag = False
if flag:
	print('YES')
	for i in range(n):
		print(s[i][1])
else:
	print('NO')


n = int(input())
m = []
for i in range(n):
	k = input()
	m.append((len(k), k))
m.sort()
flg = 0
cur_str = m[0][1]
for i in range(1, n):
	if m[i][1].find(cur_str) == -1:
		print('NO')
		flg = 1
		break
	else:
		cur_str = m[i][1]
if flg == 0:
	print('YES')
	for i in m:
		print(i[1])


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
a = []
for _ in range(n):
	a.append(input())
a.sort(key=lambda x: len(x))
for i in range(n):
	for j in range(i + 1, n):
		if a[i] not in a[j]:
			print('NO')
			exit()
print('YES')
for i in a:
	print(i)


n = int(input())
l = []
for i in range(n):
	l.append(input())
l2 = sorted(l, key=len)
for i in range(len(l2) - 1):
	if not l2[i] in l2[i + 1]:
		print('NO')
		break
else:
	print('YES')
	for e in l2:
		print(e)


n = int(input())
strings = [input() for _ in range(n)]
strings = [(len(u), u) for u in strings]
strings.sort()
strings = [u[1] for u in strings]
for p in range(n):
	st = strings[p]
	for s in range(p, n):
		if st not in strings[s]:
			print('NO')
			exit()
print('YES')
for j in strings:
	print(j)


n = int(input())
arr = [input() for k in range(n)]
arr.sort(key=len)
for i in range(1, n):
	for j in range(0, i):
		try:
			arr[i].index(arr[j])
		except Exception as _:
			print('NO')
			exit()
print('YES')
[print(k) for k in arr]


import sys
from collections import Counter

def comparing(s1, s2):
	return len(s1) < len(s2)
n = int(input())
a = []
for i in range(n):
	a.append(input())
a.sort(key=len)
for i in range(n - 1):
	if a[i] in a[i + 1]:
		continue
	else:
		print('NO')
		sys.exit(0)
print('YES')
for i in a:
	print(i)


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
N = INT()
A = [input() for i in range(N)]
A = [(len(s), s) for s in A]
A.sort()
for i in range(N - 2, -1, -1):
	s1 = A[i][1]
	s2 = A[i + 1][1]
	if not s2.count(s1):
		NO()
		exit()
YES()
[print(a[1]) for a in A]


n = int(input())
a = sorted((input() for _ in [0] * n), key=len)
print(('NO', '\n'.join(['YES'] + a))[all((x in y for (x, y) in zip(a, a[1:])))])


def isSub(a, b):
	if len(a) > len(b):
		return False
	for i in range(0, len(b) - len(a) + 1):
		if a == b[i:i + len(a)]:
			return True
	return False
n = int(input().strip())
l = []
for i in range(n):
	l.append(input().strip())
max_len = 0
for e in l:
	if len(e) > max_len:
		max_len = len(e)
big_l = [[] for i in range(max_len + 1)]
for e in l:
	big_l[len(e)].append(e)
for small_l in big_l:
	if len(small_l) < 2:
		continue
	for i in range(1, len(small_l)):
		if small_l[i] != small_l[0]:
			print('NO')
			exit(0)
cache = None
for small_l in big_l:
	if len(small_l) == 0:
		continue
	if cache == None:
		cache = small_l[0]
		continue
	if not isSub(cache, small_l[0]):
		print('NO')
		exit(0)
	else:
		cache = small_l[0]
print('YES')
for small_l in big_l:
	for e in small_l:
		print(e)


n = int(input())
st = []
for i in range(n):
	st.append(input())
st.sort(key=len)
ans = True
for i in range(n - 1):
	if not st[i] in st[i + 1]:
		ans = False
		break
if ans:
	print('YES')
	for s in st:
		print(s)
else:
	print('NO')


n = int(input())
strs = []
for i in range(n):
	temp = input()
	strs.append((temp, len(temp)))
strs = sorted(strs, key=lambda it: it[1])
flag = False
for i in range(n):
	for j in range(i + 1, n):
		if strs[i][0] not in strs[j][0]:
			flag = True
			break
if flag == True:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(strs[i][0])


n = int(input())
cad = []
while n:
	abc = input()
	cad.append(abc)
	cad = sorted(cad, key=len)
	n = n - 1
flag = True
for i in range(len(cad) - 1):
	if cad[i] not in cad[i + 1]:
		flag = False
		break
if flag:
	print('YES')
	for i in cad:
		print(i)
else:
	print('NO')


def SortingByLength(l):
	s1 = sorted(l, key=len)
	return s1
S = []
N = int(input())
for n in range(N):
	s = input()
	S.append(s)
l = SortingByLength(S)
f = 0
for i in range(len(l) - 1, 0, -1):
	if l[i - 1] not in l[i]:
		f = 1
		print('NO')
		break
if f == 0:
	print('YES')
	for i in range(len(l)):
		print(l[i])


n = int(input())
a = []
f = 1
for i in range(n):
	a += [input().strip()]
for i in range(n):
	for j in range(n):
		if a[i].find(a[j]) == -1:
			(a[i], a[j]) = (a[j], a[i])
			f = 1
for i in range(n - 1):
	if a[i + 1].find(a[i]) == -1:
		f = 0
if f == 0:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(a[i], end='\n')


import sys
n = int(input())
A = []
B = []
for i in range(n):
	s = input()
	B.append(s)
	A.append([len(s), i])
A.sort()
for i in range(1, n):
	if not B[A[i - 1][1]] in B[A[i][1]]:
		print('NO')
		sys.exit()
print('YES')
for pair in A:
	print(B[pair[1]])


from typing import List
n: int = int(input())
sequence: List[str] = []
for i in range(n):
	sequence.append(input())
sequence = sorted(sequence, key=len)
isSubs: bool = True
for i in range(n - 1):
	for j in range(i + 1, n):
		if sequence[i] not in sequence[j]:
			isSubs = False
			break
	if not isSubs:
		break
if isSubs:
	print('YES')
	for i in range(n):
		print(sequence[i])
else:
	print('NO')


MAX_WORD = '1' * 10000
n = int(input())
a = list()
for i in range(n):
	x = input()
	a.append(x)
a.sort(key=len)
busy = list((False for _ in range(n)))
busy[0] = True
ans = list([a[0]])
check = True
i = 0
while i < n and check:
	check = False
	res = MAX_WORD
	for j in range(n):
		if a[j].find(ans[i]) != -1 and len(a[j]) < len(res) and (not busy[j]):
			res = a[j]
	for j in range(n):
		if a[j] == res and (not busy[j]):
			busy[j] = True
			break
	if res != MAX_WORD:
		ans.append(res)
		check = True
	i += 1
if len(ans) == n:
	print('YES')
	for i in range(n):
		print(ans[i])
else:
	print('NO')


import sys
import bisect
import math as mt
t = 1
mod = 10 ** 9 + 7
for _ in range(t):
	n = int(input())
	d = {}
	l1 = []
	for i in range(n):
		s = input()
		if d.get(len(s), -1) == -1:
			d[len(s)] = []
		d[len(s)].append(s)
		l1.append(len(s))
	l1 = list(set(l1))
	l1.sort(reverse=True)
	n1 = len(l1)
	ch = 1
	for i in range(n1):
		s1 = d[l1[i]][0]
		for j in d[l1[i]]:
			if s1 != j:
				ch = 0
				break
	for i in range(n1):
		s1 = d[l1[i]][0]
		for j in range(i + 1, n1):
			s2 = d[l1[j]][0]
			if s1.count(s2) == 0:
				ch = 0
				break
	if ch == 0:
		print('NO')
	else:
		print('YES')
		for i in range(n1 - 1, -1, -1):
			for j in d[l1[i]]:
				print(j)


n = int(input())
strings = []
for _ in range(n):
	strings.append(input())
strings = sorted(strings, key=lambda s: len(s))
success = True
for i in range(n - 1):
	if strings[i] not in strings[i + 1]:
		success = False
		break
if success:
	print('YES')
	print('\n'.join(strings))
else:
	print('NO')


n = int(input())
s = []
for i in range(n):
	string = input()
	s.append([len(string), string])
s.sort()

def isSubstr(s1, s2):
	k = len(s1)
	f = False
	for i in range(len(s2) - k + 1):
		if s1 == s2[i:i + k]:
			f = True
			break
	return f
ans = 'YES'
for i in range(n - 1):
	if not isSubstr(s[i][1], s[i + 1][1]):
		ans = 'NO'
		break
print(ans)
if ans[0] != 'N':
	for pair in s:
		print(pair[1])


n = int(input())
lst_str = []
for i in range(n):
	string = input()
	lst_str.append(string)
lst2 = sorted(lst_str, key=len)
for a in range(0, len(lst2)):
	if a == len(lst2) - 1:
		continue
	if lst2[a] not in lst2[a + 1]:
		print('NO')
		break
else:
	print('YES')
	for i in lst2:
		print(i)


n = int(input())
x = []
for i in range(n):
	x.append(input())
x = sorted(x, key=len)
t = 0
for i in range(n):
	if i == n - 1:
		break
	if x[i] in x[i + 1]:
		t += 1
if t == n - 1:
	print('YES')
	for k in range(n):
		print(x[k])
else:
	print('NO')


n = int(input())
a = []
for i in range(n):
	a.append(str(input()))
a = sorted(a, key=len)
f = 0
for i in range(0, n - 1):
	if a[i] not in a[i + 1]:
		f = 1
if f == 1:
	print('NO')
else:
	print('YES')
	for i in a:
		print(i)


def get_prefix_arr(pattern, b):
	prefix_arr = [0] * b
	n = 0
	m = 1
	while m != b:
		if pattern[m] == pattern[n]:
			n += 1
			prefix_arr[m] = n
			m += 1
		elif n != 0:
			n = prefix_arr[n - 1]
		else:
			prefix_arr[m] = 0
			m += 1
	return prefix_arr

def KMPSearch(pat, txt):
	M = len(pat)
	N = len(txt)
	lps = get_prefix_arr(pat, M)
	j = 0
	i = 0
	while i < N:
		if pat[j] == txt[i]:
			i += 1
			j += 1
		if j == M:
			j = lps[j - 1]
			return 1
		elif i < N and pat[j] != txt[i]:
			if j != 0:
				j = lps[j - 1]
			else:
				i += 1
	return 0

def sort(lst, n):
	for i in range(n):
		md = i
		for j in range(i + 1, n):
			if KMPSearch(lst[md], lst[j]) == 0:
				if KMPSearch(lst[j], lst[md]) == 0:
					return 'NO'
				md = j
		(lst[md], lst[i]) = (lst[i], lst[md])
	return 'YES'
n = int(input())
lst = []
for i in range(n):
	s = input()
	lst.append(s)
x = sort(lst, n)
print(x)
if x == 'YES':
	for i in range(n):
		print(lst[i])


n = int(input())
l = [input() for x in range(n)]
s = sorted(l, key=len)
c = 0
for i in range(n - 1):
	a = s[i]
	b = s[i + 1]
	if b.find(a) != -1:
		c = c + 1
if c == n - 1:
	print('YES')
	for i in range(n):
		print(s[i])
else:
	print('NO')


def sortare(e):
	return len(e)
n = int(input())
l = []
lista = []
sett = set()
for i in range(n):
	s = str(input())
	sett.add(s)
	lista.append(s)
l = list(sett)
l.sort(key=sortare, reverse=True)
lista.sort(key=sortare, reverse=False)
n = len(l)
if n == 1:
	print('YES')
	for i in range(len(lista)):
		print(lista[i])
	exit(0)
nr = 1
for i in range(0, n - 1):
	if l[i].count(l[i + 1]) > 0:
		nr = nr + 1
if nr == n:
	print('YES')
	for i in range(len(lista)):
		print(lista[i])
else:
	print('NO')


n = int(input())
s = []
for i in range(n):
	s.append(input())
for i in range(n - 1):
	for j in range(i, n):
		if s[j] in s[i]:
			(s[i], s[j]) = (s[j], s[i])
error = 'YES'
for i in range(n - 1):
	if not s[i] in s[i + 1]:
		error = 'NO'
print(error)
if error == 'YES':
	for i in s:
		print(i)


n = int(input())
arr = []
for _ in range(n):
	s = input().strip()
	arr.append([len(s), s])
arr.sort()
for i in range(n):
	flag = 0
	for j in range(i + 1, n):
		if arr[i][1] not in arr[j][1]:
			flag = 1
			break
	if flag == 1:
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(arr[i][1])


n = int(input())
a = [input() for x in range(n)]
for i in range(n - 1):
	for j in range(i + 1, n):
		if a[j] in a[i]:
			(a[i], a[j]) = (a[j], a[i])
for x in range(n - 1):
	if a[x] not in a[x + 1]:
		print('NO')
		exit()
print('YES')
for x in a:
	print(x)


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


def aux_strings(a, b):
	for i in range(len(b) - len(a) + 1):
		if a == b[i:len(a) + i]:
			return -1
	return None

def cmp_strings(a, b):
	if a == b:
		return 0
	elif len(a) < len(b):
		return aux_strings(a, b)
	elif len(b) < len(a):
		cmp = aux_strings(b, a)
		if cmp is not None:
			return aux_strings(b, a) * -1
		return None
	else:
		return None

def quicksort(v, p, r):
	if p < r:
		q = particionar(v, p, r)
		if q is None:
			return q
		if quicksort(v, p, q - 1) is None:
			return None
		if quicksort(v, q + 1, r) is None:
			return None
	return True

def particionar(v, p, r):
	x = v[p]
	i = p
	j = p + 1
	while j <= r:
		cmp = cmp_strings(v[j], x)
		if cmp is None:
			return cmp
		if cmp == -1:
			i += 1
			trocar(v, i, j)
		j += 1
	trocar(v, p, i)
	return i

def trocar(v, n, m):
	temp = v[n]
	v[n] = v[m]
	v[m] = temp
n = int(input())
vetor = []
for i in range(n):
	vetor.append(input())
ordenou = quicksort(vetor, 0, len(vetor) - 1)
if ordenou:
	print('YES')
	for e in vetor:
		print(e)
else:
	print('NO')


n = input()
n = int(n)
status = 1
list = []
i = 0
while i < n:
	str = input()
	list.append(str)
	i += 1
ml = sorted(list, key=len)
i = 0
while i < n - 1:
	if ml[i] in ml[i + 1]:
		status = 1
	else:
		status = 0
		break
	i += 1
if status == 1:
	print('YES')
	for i in range(n):
		print(ml[i])
else:
	print('NO')


n = int(input())
(l, temp) = ([], [])
for i in range(n):
	l.append(input().strip())
	temp.append(len(l[i]))
for i in range(n):
	for j in range(i + 1, n):
		if temp[i] > temp[j]:
			(temp[i], temp[j]) = (temp[j], temp[i])
			(l[i], l[j]) = (l[j], l[i])
flag = 0
for i in range(n - 1):
	if l[i + 1].find(l[i]) == -1:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in l:
		print(i)


sl = sorted([input() for i in range(int(input()))], key=len)
print(('NO', '\n'.join(['YES'] + sl))[all((x in y for (x, y) in zip(sl, sl[1:])))])


def solve(arr):
	for i in range(0, len(arr) - 1):
		x = arr[i + 1].find(arr[i])
		if x == -1:
			return 0
	return 1
n = int(input())
arr = []
while n:
	s = str(input())
	arr.append(s)
	n = n - 1
arr.sort(key=len)
flag = solve(arr)
if flag:
	print('YES')
	for i in arr:
		print(i)
else:
	print('NO')


def check(w):
	for i in range(1, len(w)):
		if w[i - 1] in w[i]:
			continue
		else:
			return 0
	return 1
n = int(input())
w = []
for i in range(n):
	w.append(input())
w.sort(key=len)
if check(w):
	print('YES')
	for i in range(len(w)):
		print(w[i])
else:
	print('NO')


ans = []
for _ in range(int(input())):
	n = input()
	ans.append([len(n), n])
ans.sort()
for i in range(len(ans) - 1):
	if ans[i][1] not in ans[i + 1][1]:
		print('NO')
		exit()
print('YES')
for i in range(len(ans)):
	print(ans[i][1], sep=' ')


import sys

def rr():
	return sys.stdin.readline().rstrip()

def rri():
	return int(rr())

def rrl():
	return list(map(int, rr().split()))

def rrt():
	return tuple(map(int, rr().split()))

def rrle():
	return (line.rstrip() for line in sys.stdin.readlines())

def rrtl():
	return [tuple(map(int, l.split())) for l in rrle()]
from collections import defaultdict

def mus(d=lambda : 0):
	return defaultdict(lambda : defaultdict(d))

def dd0(d=lambda : 0):
	return defaultdict(d)

def ms(x, y, d=0):
	return [[0] * y for i in range(x)]

def ar(x, d=0):
	return [d] * x

def ppm(m, n=0, x=0, y=0):
	print('\n'.join(('\t'.join((str(m[j][i]) for j in range(y or n))) for i in range(x or n))))

def ppa(a, n):
	print('\t'.join(map(str, a[0:n])))

def ppl(a=0, x=[1]):
	x[0] = a or x[0] + 1
	print('-' + '- -' * 14 + '-# ' + str(x[0] - 2) + ' #-' + '- -' * 14 + '-')

def fltn(a):
	(i for sub in a for i in sub)

def yn(x):
	return 'YES' if x else 'NO'
from itertools import accumulate
from itertools import groupby
from itertools import permutations

def grp(x, key=None):
	return ((i, sum((1 for _ in g))) for (i, g) in groupby(x, key=key))
import math

def rnar():
	return (*rrl(), rrl())

def rn():
	return (*rrl(),)

def dpp(a, b=''):
	print('#| {} |#:^ {} ^:'.format(a, b))
MOD17 = 10 ** 9 + 7

def read():
	rri()
	l = list(rrle())
	return (l,)

def solve(arr):
	arr.sort(reverse=True, key=len)
	prev = ''
	ans = False
	db = False
	for (ln, group) in groupby(arr, len):
		i1 = next(group)
		if not prev:
			prev = i1
		if i1 not in prev:
			break
		prev = i1
		for item in group:
			if not item == i1:
				break
		else:
			continue
		break
	else:
		ans = True
	if ans:
		ans = yn(ans) + '\n' + '\n'.join(reversed(arr))
	else:
		ans = yn(ans)
	return ans
test_count = 1
for _ in range(test_count):
	input_data = read()
	result = solve(*input_data)
	print(result)


import math

def fact(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
	return ans

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
n = int(input())
w = []
ok = True
for i in range(n):
	w.append(str(input()))
w = sorted(w, key=lambda x: len(x))
for i in range(n - 1):
	for s in range(i, n):
		if w[i] not in w[s]:
			ok = False
			break
	if not ok:
		break
if ok:
	print('YES')
	for i in range(n):
		print(w[i])
else:
	print('NO')


n = int(input())
a = []
for i in range(n):
	a.append(str(input()))
a.sort(key=lambda x: len(x))
for i in range(n - 1):
	if a[i] in a[i + 1]:
		continue
	else:
		print('NO')
		exit()
print('YES')
print(*a, sep='\n')


n = int(input())
list1 = []
for i in range(n):
	str1 = input()
	list1.append(str1)
list1.sort(key=len)
flag = 0
for i in range(len(list1) - 1):
	if list1[i] not in list1[i + 1]:
		flag = 1
		break
if flag == 0:
	print('YES')
	for i in range(n):
		print(list1[i])
else:
	print('NO')


n = int(input())
L = []
for x in range(n):
	s = input()
	L.append((len(s), s))
L = sorted(L)
pode = True
for i in range(n - 1):
	if L[i][1] not in L[i + 1][1]:
		pode = False
if not pode:
	print('NO')
else:
	print('YES')
	for x in L:
		print(x[1])


import sys
import collections
from collections import Counter
import itertools
import math
import timeit

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
n = ii()
d = [input() for _ in range(n)]
d.sort(key=len)
if all((d[i] in d[i + 1] for i in range(n - 1))):
	print('YES')
	prr(d, sep='\n')
else:
	print('NO')


n = int(input())
strings = [input() for _ in range(n)]
strings.sort(key=len)
i = 0
bad = False
try:
	while i < len(strings) - 1:
		if strings[i + 1].index(strings[i]):
			pass
		elif len(strings[i]) == len(strings[i + 1]) and strings[i].index(strings[i + 1]):
			(strings[i], strings[i + 1]) = (strings[i + 1], strings[i])
		i += 1
except:
	bad = True
if bad:
	print('NO')
else:
	print('YES')
	for s in strings:
		print(s)


n = int(input())
l_string = []
flag = 0
for i in range(0, n):
	s = input()
	l_string.append(s)
l_string.sort(key=lambda s: len(s))
for i in range(0, n - 1):
	if l_string[i + 1].find(l_string[i]) < 0:
		flag = 1
if flag == 1:
	print('NO')
else:
	print('YES')
	for x in l_string:
		print(x)


n = int(input())
m = n
s = []
sl = []
f = 0
for i in range(n):
	s1 = input()
	s.append(s1)
l = []
for i in range(n):
	l.append(len(s[i]))
l1 = []
for i in range(n):
	l1.append(l[i])
l.sort()
s2 = []
for i in range(n):
	s2.append(s[l1.index(l[i])])
	l1[l1.index(l[i])] = -1
for i in range(n):
	for j in range(i, n):
		if s2[i] not in s2[j]:
			f = 1
			break
	if f == 1:
		break
if f == 1:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(s2[i])


n = int(input())
output = []
for i in range(n):
	output.append(input())
for i in range(1, len(output)):
	temp = output[i]
	j = i - 1
	while j >= 0 and len(temp) < len(output[j]):
		output[j + 1] = output[j]
		j -= 1
	output[j + 1] = temp
status = False
for i in range(len(output) - 1):
	curr = output[i]
	if curr in output[i + 1]:
		status = True
	else:
		status = False
		break
if status or len(output) == 1:
	print('YES')
	for i in range(len(output)):
		print(output[i])
else:
	print('NO')


import sys
n = int(input())
a = []
for i in range(n):
	a.append(input())

def f(d):
	return len(d)
a.sort(key=f)
for i in range(1, n):
	if not a[i - 1] in a[i]:
		print('NO')
		sys.exit()
print('YES')
for i in a:
	print(i)


def sortByLength(inputStr):
	return len(inputStr)
n = int(input())
a = []
for i in range(n):
	a.append(input())
a = sorted(a, key=sortByLength)
boolean = True
for i in range(n):
	if i != n - 1 and a[i] not in a[i + 1]:
		boolean = False
if boolean is True:
	print('YES')
	for i in range(n):
		print(a[i])
else:
	print('NO')


def test_2():
	import math
	from collections import Counter
	n = list(map(int, input().split(' ')))[0]
	data = []
	for i in range(n):
		data.append(input().strip())
	data.sort(key=lambda x: len(x))
	out = []
	for i in range(len(data) - 1):
		if data[i + 1].find(data[i]) != -1:
			out.append(data[i])
		else:
			print('NO')
			return
	out.append(data[-1])
	print('YES')
	print('\n'.join(out))
test_2()


li = []
for _ in range(int(input())):
	str1 = input()
	li += [[len(str1), str1]]
li.sort()
for i in range(1, len(li)):
	for j in range(i):
		if li[j][1] not in li[i][1]:
			print('NO')
			exit()
else:
	print('YES')
	for i in range(len(li)):
		print(li[i][1])


n = int(input())
strings = {}
for i in range(n):
	new_s = input()
	if new_s not in strings.keys():
		strings.update({new_s: [1, 0]})
	else:
		strings[new_s][0] += 1
for s1 in strings.keys():
	for s2 in strings.keys():
		if s1 == s2:
			continue
		if s1 in s2:
			strings[s1][1] += 1
if list(range(0, len(strings))) != sorted([strings[s][1] for s in strings.keys()]):
	print('NO')
else:
	print('YES')
	while len(strings) != 0:
		mx = -1
		mx_s = ''
		for s in strings.keys():
			if strings[s][1] > mx:
				mx = strings[s][1]
				mx_s = s
		for i in range(strings[mx_s][0]):
			print(mx_s)
		strings.__delitem__(mx_s)


import logging
fmt = '%(levelname)s - %(name)s (line:%(lineno)s) - %(message)s'
formatter = logging.Formatter(fmt)
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
ch.setFormatter(formatter)
logger = logging.getLogger('substrings_sort')
logger.setLevel(logging.ERROR)
logger.addHandler(ch)

class SubString:

	def __init__(self, s):
		self.s = s

	def __lt__(self, other):
		if not self._check(other):
			raise Exception('Not possible')
		return self.s in other.s and len(self.s) < len(other.s)

	def __le__(self, other):
		if not self._check(other):
			raise Exception('Not possible')
		return self.s in other.s and len(self.s) == len(other.s)

	def __eq__(self, other):
		if not self._check(other):
			raise Exception('Not possible')
		return self.s == other.s

	def _check(self, other):
		if self.s in other.s or other.s in self.s:
			return True
		return False

	def __repr__(self):
		return self.s

def solve(seq):
	tmp = []
	for s in seq:
		tmp.append(SubString(s))
	try:
		return [x.s for x in sorted(tmp)]
	except:
		return None

def main():
	n = int(input().strip())
	seq = [input().strip() for _ in range(n)]
	result = solve(seq)
	if result:
		print('YES')
		print('\n'.join(result))
	else:
		print('NO')
main()


n = int(input())
a = []
for i in range(n):
	a.append(input().strip())
for i in range(n):
	for j in range(i + 1, n):
		if a[j] in a[i]:
			(a[j], a[i]) = (a[i], a[j])
ans = 'YES'
for i in range(n - 1):
	if a[i] in a[i + 1]:
		continue
	else:
		ans = 'NO'
if ans == 'YES':
	print('YES')
	for i in a:
		print(i)
else:
	print('NO')


t = int(input())
f = []
while t:
	a = input()
	f.append(a)
	t -= 1
f.sort()
f.sort(key=len)
r = 'YES'
for i in range(len(f) - 1):
	if f[i] not in f[i + 1]:
		r = 'NO'
		break
if r == 'YES':
	print(r)
	for i in f:
		print(i)
else:
	print('NO')


num = int(input())
less = 0
ind = 0
flag = 0
arr = []
for i in range(0, num):
	n = str(input())
	arr.append(n)
m = 1
for i in range(0, num):
	for j in range(i + 1, num):
		if len(arr[i]) > len(arr[j]):
			temp = arr[i]
			arr[i] = arr[j]
			arr[j] = temp
while m <= num - 1:
	k = arr[m].find(arr[m - 1])
	if k == -1:
		print('NO')
		flag = 1
		break
	m = m + 1
if flag != 1:
	print('YES')
	for i in range(0, num):
		print(arr[i])


def main():
	N = int(input())
	str = []
	length = []
	result = []
	present = 1
	for i in range(N):
		new = input()
		str.append(new)
		length.append(len(new))
	for i in range(N - 1):
		max_length_index = length.index(max(length))
		max_string = str[max_length_index]
		present = 1
		for j in range(len(str)):
			if str[j] not in max_string:
				present = 0
		if present == 1:
			result.insert(0, max_string)
			del str[max_length_index]
			del length[max_length_index]
		else:
			print('NO')
			break
	if present == 1:
		result.insert(0, str[0])
		print('YES')
		for string in result:
			print(string)
main()


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
arr = []
for _ in range(tc):
	arr.append(is1())
arr.sort(key=lambda x: (len(x), x))
for i in range(1, len(arr)):
	if arr[i - 1] not in arr[i]:
		print('NO')
		break
else:
	print('YES')
	for i in arr:
		print(i)


n = int(input())
S = []
for i in range(n):
	s = input()
	S.append([len(s), s])
S.sort()
if n == 1:
	print('YES')
	print(S[0][1])
else:
	i = 0
	j = 1
	f = -1
	while i < n - 1 and j < n:
		a = S[i][1]
		b = S[j][1]
		f = -1
		for p in range(0, S[j][0] - len(a) + 1):
			if a == b[p:p + len(a)]:
				f = 1
				break
		if f == 1:
			i += 1
			j += 1
		else:
			break
	if f == -1:
		print('NO')
	else:
		print('YES')
		for i in S:
			print(i[1])


n = int(input())
strarr = []
for _ in range(n):
	strarr.append(input())
strarr.sort(key=lambda x: len(x))
flag = True
for i in range(n - 1):
	if strarr[i] not in strarr[i + 1]:
		flag = False
		break
if flag:
	print('YES')
	for i in range(n):
		print(strarr[i])
else:
	print('NO')


n = int(input())
l = []
for t in range(n):
	l.append(str(input()))
l = sorted(l, key=lambda x: len(x))
c = 0
for y in range(len(l) - 1):
	if l[y] not in l[y + 1]:
		c = 1
		break
if c == 1:
	print('NO')
else:
	print('YES')
	for t in l:
		print(t)


n = int(input())
t = []
while n > 0:
	x = str(input())
	t.append(x)
	n -= 1
f = 1
t.sort(key=len)
y = len(t) - 1
h = 0
while h < len(t) - 1:
	z = h + 1
	while z < len(t):
		if t[h] not in str(t[z]):
			f = 0
			break
		z += 1
	h += 1
if f == 1:
	print('YES')
	print('\n'.join(t))
else:
	print('NO')


def sor(n):
	t = []
	while len(n) != 0:
		b = 0
		for i in range(len(n)):
			if len(n[i]) > b:
				c = i
				b = len(n[i])
		t += [n[c]]
		n = n[:c] + n[c + 1:]
	return t

def substring(a, b):
	for i in range(len(a) - len(b) + 1):
		if a[i:i + len(b)] == b:
			return False
	return True
n = int(input())
t = []
for i in range(n):
	t += [input()]
t = sor(t)
done = True
for i in range(n - 2, -1, -1):
	if substring(t[i], t[i + 1]):
		done = False
		break
if done:
	print('YES')
	for i in range(n - 1, -1, -1):
		print(t[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 = int(input())
l = []
for i in range(n):
	l.append(input())
l.sort(key=len)
i = 0
while i < len(l) - 1:
	if l[i + 1].find(l[i]) == -1:
		print('NO')
		exit()
	i += 1
print('YES')
for e in l:
	print(e)


a = int(input())
b = []
for i in range(a):
	b.append(input())
b = sorted(b, key=lambda x: len(x))
if all((b[i] in b[i + 1] for i in range(len(b) - 1))):
	print('YES')
	print(*b, sep='\n')
else:
	print('NO')


n = int(input())
inp = []
for i in range(n):
	inp.append(input())
sort = sorted(inp, key=len)
for i in range(n - 1):
	if sort[i] not in sort[i + 1]:
		print('NO')
		quit()
print('YES')
for element in sort:
	print(element)


n = int(input())
arr = []
for i in range(n):
	s = input()
	arr += [[len(s), s]]
flag = 0
arr.sort()
for x in range(len(arr) - 1):
	if arr[x + 1][1].find(arr[x][1]) == -1:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for x in arr:
		print(x[1])


def chk():
	for i in range(len(s) - 1):
		if s[i] not in s[i + 1]:
			return False
	return True
n = int(input())
s = sorted([input() for i in range(n)], key=len)
if chk():
	print('YES')
	for i in s:
		print(i)
else:
	print('NO')


class st:

	def __init__(self, s, n):
		self.s = s
		self.n = n
arr = []
n = int(input())
for i in range(n):
	s = input()
	arr.append(st(s, len(s)))
arr.sort(key=lambda st: st.n)
flag = 0
for i in range(n - 1):
	if arr[i + 1].s.find(arr[i].s) == -1:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in arr:
		print(i.s)


n = int(input())
s = [' ']
for i in range(1, n + 1):
	s.append(input())
s = sorted(s, key=lambda p: len(p))
b = True
for i in range(1, n):
	if not b:
		break
	for j in range(i + 1, n + 1):
		if s[j].find(s[i]) == -1:
			b = False
			break
if not b:
	print('NO')
else:
	print('YES')
	print('\n'.join(s[1:]))


from functools import cmp_to_key
import sys

def getIntList():
	return list(map(int, input().split()))
n = int(input())
z = []
for i in range(n):
	z.append(input())
for i in range(n):
	for j in range(i + 1, n):
		if z[i] not in z[j] and z[j] not in z[i]:
			print('NO')
			sys.exit()
key = cmp_to_key(lambda x, y: 1 if x not in y else -1)
z.sort(key=key)
print('YES')
for x in z:
	print(x)


arr = []
n = int(input())
flag = None
for i in range(n):
	arr.append(input())
for i in range(n):
	for j in range(n - 1, i, -1):
		if arr[j - 1].find(arr[j]) != -1:
			x = arr[j - 1]
			arr[j - 1] = arr[j]
			arr[j] = x
for i in range(1, n):
	if arr[i].find(arr[i - 1]) == -1:
		flag = True
if flag == True:
	print('NO')
else:
	print('YES')
	for i in arr:
		print(i)


n = int(input())
z = []
for i in range(n):
	z.append(input())
z.sort(key=lambda x: len(x))
for i in range(n - 1):
	if z[i] not in z[i + 1]:
		print('NO')
		exit()
print('YES')
for i in z:
	print(i)


n = int(input())
a = [0] * n
for i in range(n):
	a[i] = input().strip()
a.sort(key=len)
flag = 1
for i in range(1, n):
	if a[i - 1] not in a[i]:
		print('NO')
		flag = 0
		break
if flag:
	print('YES')
	for s in a:
		print(s)


kolvo = []
s = list()
MAX = ''
ans = 0
for i in range(int(input())):
	s.append(input())
s = sorted(s)
i = 1
while i < len(s):
	while len(s[i]) < len(s[i - 1]):
		(s[i], s[i - 1]) = (s[i - 1], s[i])
		i -= 1
		if i - 1 < 0:
			break
	i += 1
for x in range(len(s)):
	for i in range(len(s)):
		if len(s[x]) >= len(s[i]):
			if s[x].count(s[i]) == 0:
				print('NO')
				ans = 1
				break
	if ans == 1:
		break
if ans == 0:
	print('YES')
	for i in range(len(s)):
		print(s[i])


n = int(input())
strs = []
i = 0
while i < n:
	s = input()
	strs.append(s)
	i += 1
strs.sort(key=len)
i = 0
status = 1
while i < n:
	if i != n - 1:
		if strs[i] not in strs[i + 1]:
			print('NO')
			status = 0
			break
	i = i + 1
if status == 1:
	print('YES')
	for s in strs:
		print(s)


import sys

class word:
	word = ''
	counter = 0
index_list = []
my_list = []
for i in range(101):
	my_word = word()
	my_list.append(my_word)
tedad = int(input())
for i in range(tedad):
	a = input()
	if my_list[len(a)].counter == 0:
		my_list[len(a)].word = a
		my_list[len(a)].counter += 1
		index_list.append(len(a))
	elif my_list[len(a)].word != a:
		print('NO')
		sys.exit()
	else:
		my_list[len(a)].counter += 1
index_list.sort()
for i in range(len(index_list) - 1):
	if my_list[index_list[i]].word in my_list[index_list[i + 1]].word:
		continue
	else:
		print('NO')
		sys.exit()
print('YES')
for i in range(len(index_list)):
	for j in range(my_list[index_list[i]].counter):
		print(my_list[index_list[i]].word)


n = int(input())
l = []
for i in range(n):
	a = input()
	l.append([len(a), a])
l.sort()
b = []
for i in l:
	b.append(i[1])
r = 1
for i in range(n - 1):
	if b[i] not in b[i + 1]:
		print('NO')
		r = 0
		break
if r == 1:
	print('YES')
	for i in b:
		print(i)


n = int(input())
strings = sorted((input() for _ in range(n)), key=lambda x: len(x))
if all((strings[i] in strings[i + 1] for i in range(n - 1))):
	print('YES')
	for s in strings:
		print(s)
else:
	print('NO')


n = int(input())
hopha = []
for i in range(n):
	s = input()
	hopha.append([len(s), s])
hopha.sort()
fl = 0
for z in range(n - 1):
	if hopha[z][1] not in hopha[z + 1][1]:
		fl = 1
if fl:
	print('NO')
else:
	print('YES')
	for tt in hopha:
		print(tt[1])


b = sorted((input() for i in range(int(input()))), key=len)
print('YES', *b, sep='\n') if all((b[i] in b[i + 1] for i in range(len(b) - 1))) else print('NO')


def Sort(a):
	return len(a)
n = int(input())
a = []
for i in range(n):
	a.append(str(input()))
for i in range(0, len(a)):
	for j in range(0, len(a)):
		if a[i] not in a[j] and a[j] not in a[i]:
			print('NO')
			quit()
print('YES')
a.sort(key=Sort)
for i in a:
	print(i)


def sort(s, n):
	for i in range(1, n):
		temp = s[i]
		j = i - 1
		while j >= 0 and len(temp) < len(s[j]):
			s[j + 1] = s[j]
			j -= 1
		s[j + 1] = temp
x = int(input())
lis = []
for i in range(0, x):
	s = input()
	lis.append(s)
sort(lis, x)
f = 1
for i in range(0, x - 1):
	for j in range(i + 1, x):
		if lis[i] not in lis[j]:
			f = 0
			break
if f == 1:
	print('YES')
	for i in range(0, x):
		print(lis[i])
else:
	print('NO')


n = int(input())
l = []
for i in range(n):
	x = input()
	l.append(x)
l = sorted(l, key=len)
flag = 1
for i in range(n - 1):
	if l[i] not in l[i + 1]:
		flag = 0
		break
if flag:
	print('YES')
	for i in l:
		print(i)
else:
	print('NO')


n = int(input())
lst = []
for i in range(n):
	s = str(input())
	lst.append(s)
lst = sorted(lst, key=len)
p = lst[0]
ans = [p]
k = 'YES'
for i in range(1, n):
	if p in lst[i]:
		ans.append(lst[i])
		p = lst[i]
	else:
		k = 'NO'
		break
print(k)
if k == 'YES':
	for i in range(n):
		print(ans[i])


n = int(input())
s = []
for i in range(n):
	s.append(input())
s.sort(key=lambda x: len(x))
flag = True
for i in range(1, n):
	if s[i].count(s[i - 1]) == 0:
		print('NO')
		flag = False
		break
if flag:
	print('YES')
	print('\n'.join(s))


n = int(input())
l = []
no = True
for i in range(n):
	s = input()
	if len(l) == 0:
		l.append(s)
	else:
		j = 0
		while j < len(l) and l[j] in s:
			j += 1
		if j == len(l):
			l.append(s)
		elif s in l[j]:
			l.insert(j, s)
		else:
			no = False
			break
if no:
	print('YES')
	print('\n'.join(l))
else:
	print('NO')


from bisect import bisect_left, bisect_right
n = int(input())
a = sorted([input() for i in range(n)], key=len)
yes = True
for i in range(1, n):
	if len(a[i]) == len(a[i - 1]):
		if a[i] != a[i - 1]:
			yes = False
			break
	elif a[i - 1] not in a[i]:
		yes = False
		break
if yes:
	print('YES')
	for i in a:
		print(i)
else:
	print('NO')


N = int(input())
A = []
for a in range(N):
	A.append(input())
ans = []
while A != []:
	found = None
	for (i, s) in enumerate(A):
		f = True
		for (j, u) in enumerate(A):
			if u not in s:
				f = False
				break
		if f:
			found = s
			ans += [found]
			A.remove(s)
			break
	if not found:
		break
if len(ans) != N:
	print('NO')
else:
	print('YES')
	for i in range(len(ans) - 1, -1, -1):
		print(ans[i])


n = int(input())
l = []
for i in range(n):
	l.append(input())
l.sort(key=lambda x: len(x))
c = 1
fg = 0
for i in range(n - 1, 0, -1):
	if l[i - 1] not in l[i]:
		fg = 1
		break
if fg == 1:
	print('NO')
if fg == 0:
	print('YES')
	for i in l:
		print(i)


n = int(input())
strings = [input().strip() for _ in range(n)]
strings.sort(key=len)
s = ''
for string in strings:
	if len(string) == len(s):
		if string == s:
			continue
		else:
			print('NO')
			exit()
	elif s in string:
		s = string
	else:
		print('NO')
		exit()
print('YES')
print(*strings, sep='\n')


n = int(input())
l = []
for i in range(n):
	l.append(input())
l = sorted(l, key=lambda s: len(s))
f = 0
for i in range(n - 1):
	for j in range(i + 1, n):
		if l[i] not in l[j]:
			f = 1
			break
	if f == 1:
		break
if f == 1:
	print('NO')
else:
	print('YES')
	for i in l:
		print(i)


import sys
f = sys.stdin
n = int(f.readline())
a = list()
for _ in range(n):
	a.append(f.readline().rstrip())
a = sorted(a, key=lambda x: len(x))
found = False
for (i, x) in enumerate(a):
	if i == 0:
		continue
	if a[i - 1] not in x:
		found = True
		break
if found:
	print('NO')
else:
	print('YES')
	for x in a:
		print(x)


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)


t = int(input())
a = []
c = 0
for i in range(t):
	x = input()
	a.append(x)
a.sort(key=len)
for i in range(t - 1):
	if a[i] in a[i + 1]:
		c = c + 1
if c == len(a) - 1:
	print('YES')
	print(*a, sep='\n')
else:
	print('NO')


from __future__ import print_function
import sys
import math
import os.path

def log(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

def ni():
	return map(int, input().split())

def nio(offset):
	return map(lambda x: int(x) + offset, input().split())

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

def toString(aList, sep=' '):
	return sep.join((str(x) for x in aList))

def toMapInvertIndex(aList):
	return {k: v for (v, k) in enumerate(aList)}
(n,) = ni()
a = [input() for _ in range(n)]
a.sort(key=len)

def check():
	for i in range(n):
		for j in range(i):
			if a[j] not in a[i]:
				return False
	return True
if check():
	print('YES')
	print(toString(a, '\n'))
else:
	print('NO')


def gogogo():
	n = int(input())
	words = [input()]
	for i in range(0, n - 1):
		word = input()
		for j in range(0, i + 1):
			if word in words[j]:
				words = words[:j] + [word] + words[j:]
				break
		else:
			if words[-1] in word:
				words.append(word)
			else:
				return False
	return words
while True:
	answer = gogogo()
	if answer == False:
		print('NO')
	else:
		for i in range(0, len(answer) - 1):
			if answer[i] not in answer[i + 1]:
				print('NO')
				break
		else:
			print('YES')
			for a in answer:
				print(a)
	break


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')


def comp(a, b):
	return len(a) <= len(b) and (not a not in b)

def merge(v):
	if len(v) <= 1:
		return v
	m = int(len(v) / 2)
	l = merge(v[:m])
	r = merge(v[m:])
	t1 = len(l)
	t2 = len(r)
	tt = t1 + t2
	aux = []
	idl = 0
	idr = 0
	for j in range(tt):
		if idl == t1:
			aux.append(r[idr])
			idr += 1
			continue
		if idr == t2:
			aux.append(l[idl])
			idl += 1
			continue
		if comp(r[idr], l[idl]):
			aux.append(r[idr])
			idr += 1
		else:
			aux.append(l[idl])
			idl += 1
	return aux
n = int(input())
a = []
verf = 0
maior = -1
ind = 0
for i in range(n):
	a.append(input())
a = merge(a)
for i in range(n - 1):
	if a[i] not in a[i + 1]:
		verf = 1
		break
if verf == 0:
	print('YES')
	for i in range(n):
		print(a[i])
else:
	print('NO')


T = int(input())
l = []
for test in range(T):
	s = input()
	l.append(s)
l.sort(key=len)
for i in range(1, T):
	if l[i - 1] not in l[i]:
		print('NO')
		exit(0)
print('YES')
for el in l:
	print(el)


n = int(input())
a = []
for i in range(n):
	a.append(input())
ans = []
while a:
	l = 0
	for i in range(len(a)):
		if len(a[i]) > l:
			l = len(a[i])
			x = a[i]
			j = i
	ans.append(x)
	a.pop(j)
fl = True
for i in range(n - 1):
	if ans[i + 1] not in ans[i]:
		print('NO')
		fl = False
		break
if fl:
	print('YES')
	for i in range(n - 1, -1, -1):
		print(ans[i])


n = int(input(''))
l = list()
for x in range(0, n):
	s = input('')
	l.append(s)
lst = sorted(l, key=len)
if len(lst) == 1:
	print('YES')
	print(lst[0])
else:
	for k in range(0, len(lst) - 1):
		if lst[k] in lst[k + 1]:
			if k == len(lst) - 2:
				print('YES')
				for x in lst:
					print(x)
		else:
			print('NO')
			break


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

def solve(n, s):
	for i in range(n - 1):
		for j in range(i + 1, n):
			if s[j] in s[i]:
				(s[i], s[j]) = (s[j], s[i])
			elif s[i] not in s[j]:
				return False
	return s
ans = solve(n, s)
if ans:
	print('YES')
	print('\n'.join(s))
else:
	print('NO')


from sys import stdin, stdout

def rint():
	return map(int, stdin.readline().split())
n = int(input())
s = []
for i in range(n):
	tmp = input()
	s.append(tmp)
s.sort(key=lambda x: len(x))
for i in range(0, n - 1):
	if not s[i] in s[i + 1]:
		print('NO')
		exit()
print('YES')
for i in range(n):
	print(s[i])


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')
		exit(0)
print('YES')
print('\n'.join((x for x in 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
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())
h = 0
status = True
lis = []
while h < n:
	lis.append(input())
	h += 1
lis.sort(key=len)
h = 0
while h < len(lis) - 1:
	if lis[h] not in lis[h + 1]:
		status = False
		break
	h += 1
if status:
	print('YES')
	h = 0
	while h < len(lis):
		print(lis[h])
		h += 1
else:
	print('NO')


n = int(input())
strings = []
for i in range(n):
	s = input()
	strings.append(s)
strings.sort(key=len)
last = strings[n - 1]
instr = True
for i in range(0, n - 1):
	if strings[i] not in last or strings[i] not in strings[i + 1]:
		instr = False
if instr:
	print('YES')
	for i in strings:
		print(i)
else:
	print('NO')


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
n = ii()
l = []
for i in range(n):
	s = si()
	l.append([len(s), s])
l.sort()
for i in range(n - 1):
	if not l[i][1] in l[i + 1][1]:
		exit(print('NO'))
print('YES')
[print(i[1]) for i in l]


def is_non_decreasing(List):
	count = 0
	for i in range(1, len(List)):
		if List[i] >= List[i - 1]:
			count += 1
	if count == len(List) - 1:
		return True
	else:
		return False
n = int(input())
List = []
for i in range(n):
	List.append(input())
Order = [0] * n
for i in range(n):
	for j in range(n):
		if List[i] in List[j]:
			Order[i] += 1
Final = []
if is_non_decreasing(sorted(Order)):
	for i in sorted(Order, reverse=True):
		idx = Order.index(i)
		Order.remove(i)
		Final.append(List[idx])
		List.remove(List[idx])
	count = 0
	for i in range(len(Final) - 1):
		if Final[i] in Final[i + 1]:
			count += 1
	if count == len(Final) - 1:
		print('YES')
		for i in range(len(Final)):
			print(Final[i])
		exit(0)
print('NO')
exit(0)


n = int(input())
s = list()
for i in range(n):
	inp = input()
	s.append([len(inp), inp])
s.sort()
possible = True
for i in range(1, n):
	if s[i - 1][1] not in s[i][1]:
		possible = False
if possible:
	print('YES')
	for i in s:
		print(i[1])
else:
	print('NO')


n = int(input())
string_list = []
string_len = []
sorted_list = []
for i in range(n):
	s = input()
	string_len.append(len(s))
	string_list.append(s)
for i in range(n):
	for j in range(i + 1, n):
		if string_len[i] > string_len[j]:
			(string_len[i], string_len[j]) = (string_len[j], string_len[i])
			(string_list[i], string_list[j]) = (string_list[j], string_list[i])
cheak = True
for i in range(n - 1):
	if string_list[i] in string_list[i + 1]:
		sorted_list.append(string_list[i])
	else:
		cheak = False
		break
sorted_list.append(string_list[n - 1])
if cheak == True:
	print('YES')
	for x in sorted_list:
		print(x)
else:
	print('NO')


import sys
from collections import defaultdict

def main(args):
	n = int(input())
	words = [input() for _ in range(n)]
	words = sorted(words, key=len)
	check = lambda word, i: all((words[j] in word for j in range(i)))
	if not all((check(word, i) for (i, word) in enumerate(words))):
		return print('NO')
	print('YES')
	print('\n'.join((word for word in words)))
sys.exit(main(sys.argv))


import functools
n = int(input())
l = sorted([input() for _ in range(n)], key=functools.cmp_to_key(lambda x, y: -1 if x in y else 1))
ans = 'YES' if all([all([l[j] in l[i] for j in range(i)]) for i in range(n)]) else 'NO'
print('%s\n%s' % (ans, '\n'.join(l) if ans == 'YES' else ''))


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
arr = sorted(arr, key=lambda s: len(s))
for i in range(len(arr) - 1):
	if arr[i + 1].find(arr[i]) == -1:
		print('NO')
		exit()
print('YES')
for i in arr:
	print(i)


n = int(input())
a = []
for i in range(n):
	a.append(input())
a.sort(key=lambda s: len(s))

def check(a, b):
	if b.find(a) == -1:
		return False
	else:
		return True
temp = True
for i in range(n - 1):
	temp &= check(a[i], a[i + 1])
if temp == False:
	print('NO')
else:
	print('YES')
	for i in a:
		print(i)


from sys import stdin

class heap_node:

	def __init__(self, string):
		self.string = string
		self.size = len(string)

class max_heap:

	def __init__(self, vec):
		self.maxHeap = vec

	def insert(self, node):
		self.maxHeap.append(node)
		self.heapify()
		return self.maxHeap

	def heapify(self):
		n = len(self.maxHeap) // 2
		for i in range(n, -1, -1):
			self.__heapify(len(self.maxHeap), i)

	def __heapify(self, n, i):
		l = 2 * i + 1
		r = 2 * i + 2
		largest = i
		if l < n and self.maxHeap[l].size > self.maxHeap[largest].size:
			largest = l
		if r < n and self.maxHeap[r].size > self.maxHeap[largest].size:
			largest = r
		if i != largest:
			(self.maxHeap[i], self.maxHeap[largest]) = (self.maxHeap[largest], self.maxHeap[i])
			self.__heapify(n, largest)

	def sort(self):
		self.heapify()
		sorted_vec = []
		n = len(self.maxHeap)
		for i in range(n - 1, -1, -1):
			sorted_vec.append(self.maxHeap[0])
			(self.maxHeap[0], self.maxHeap[i]) = (self.maxHeap[i], self.maxHeap[0])
			self.__heapify(i, 0)
		return sorted_vec

def isValid(sorted_vec):
	for i in range(len(sorted_vec) - 1, 0, -1):
		if not sorted_vec[i].string in sorted_vec[i - 1].string:
			return False
	return True
n_strings = int(input())
string_vec = []
for _ in range(n_strings):
	string = input()
	string_vec.append(heap_node(string))
heap = max_heap(string_vec)
sorted_vec = heap.sort()
if not isValid(sorted_vec):
	print('NO')
else:
	print('YES')
	for i in range(n_strings - 1, -1, -1):
		print(sorted_vec[i].string)


n = int(input())
data = [input() for _ in range(n)]
data.sort(key=lambda x: len(x))
for i in range(n):
	for j in range(i + 1, n):
		if data[i] not in data[j]:
			print('NO')
			exit()
print('YES')
for e in data:
	print(e)


n = int(input())
l = []
flag = 0
for i in range(n):
	s = input()
	l.append(s)
l2 = sorted(l, key=len)
for i in range(n - 1):
	if l2[i + 1].find(l2[i]) == -1:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in l2:
		print(i)


n = int(input())
l = []
for i in range(n):
	l.append(input())
l.sort(key=len)
b = True
for i in range(n - 1):
	if l[i] not in l[i + 1]:
		b = False
if b:
	print('YES')
	print(*l, sep='\n')
else:
	print('NO')


def solve(inlist, n):
	prev = inlist[0]
	res = True
	for i in range(n):
		if prev in inlist[i]:
			prev = inlist[i]
		else:
			res = False
			print('NO')
			break
	if res == True:
		print('YES')
		print('\n'.join(inlist))
n = int(input())
inlist = []
for i in range(n):
	inlist.append(input())
inlist.sort(key=len)
solve(inlist, n)


n = int(input())
l1 = []
while n:
	s = input()
	l1.append(s)
	n -= 1
k = sorted(l1, key=len)
c = 0
for i in range(len(k) - 1):
	if k[i] in k[i + 1]:
		c += 1
if c == len(k) - 1:
	print('YES')
	for i in k:
		print(i)
else:
	print('NO')


n = int(input())
str = []
for i in range(n):
	str.append(input())
str.sort(key=lambda s: len(s))
counter = 0
for i in range(len(str) - 1):
	if str[i] in str[i + 1]:
		counter += 1
if counter == len(str) - 1:
	print('YES')
	for i in range(len(str)):
		print(str[i])
else:
	print('NO')


n = int(input())
A = []
while n > 0:
	s = input()
	A.append(s)
	n -= 1
x = str()
cnt = -1
A.sort(key=len)
for i in A:
	if i.find(x) is -1:
		cnt += 1
	x = i
if cnt is -1:
	print('YES')
	for i in A:
		print(i)
else:
	print('NO')


n = int(input())
strs = []
for i in range(n):
	strs.append(input())
strs.sort(key=len)
prev = ''
ok = True
for s in strs:
	if not prev in s:
		ok = False
		break
	prev = s
if ok:
	print('YES')
	for s in strs:
		print(s)
else:
	print('NO')


import os
import gc
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 10 ** 9 + 7

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def solve(n):
	pass

def main():
	n = iin()
	x = deque([])
	for _ in range(n):
		x.append(sin())
	l = sorted(x, key=len)
	flag = 0
	for i in range(n - 1):
		if l[i] not in l[i + 1]:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')
		for i in range(n):
			print(l[i])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


l = []
for _ in range(int(input())):
	l.append(input().strip())
l = sorted(l, key=lambda x: len(x))
l1 = [l[0]]
for i in range(1, len(l)):
	if l1[-1] in l[i]:
		l1.append(l[i])
	else:
		break
if len(l1) != len(l):
	print('NO')
	exit()
print('YES')
for i in l1:
	print(i)


n = int(input())
a = sorted((input() for _ in range(n)), key=lambda b: len(b))
v = all((a[i] in a[i + 1] for i in range(n - 1)))
print('YES\n' + '\n'.join(a) if v else 'NO')


from collections import OrderedDict
n = input()
n = int(n)
lista = []
for i in range(0, n):
	str = input()
	lista.append(str)
lista.sort()
lista.sort(key=len)
sw = True
for i in range(0, n - 1):
	if lista[i + 1].find(lista[i]) == -1:
		sw = False
		break
if sw:
	print('YES')
	for i in range(0, n):
		print(lista[i])
else:
	print('NO')


(n, a) = (int(input()), [])
for i in range(n):
	a.append(input())
for i in range(n - 1, -1, -1):
	for j in range(i):
		if i != j and a[i] in a[j]:
			(a[i], a[j]) = (a[j], a[i])
b = 1
for i in range(1, n):
	if not a[i - 1] in a[i]:
		b = 0
if b:
	print('YES')
	for i in range(n):
		print(a[i])
else:
	print('NO')


n = int(input())
a = []
for _ in range(n):
	a.append(input())
b = sorted(a, key=len, reverse=True)
x = b[0]
i = 1
while i < n:
	if x.find(b[i]) == -1:
		break
	else:
		x = b[i]
		i = i + 1
if i == n:
	print('YES')
	l = sorted(a, key=len)
	for j in l:
		print(j)
else:
	print('NO')


n = int(input())
wordList = []
for _ in range(n):
	wordList.append(input())
wordList.sort()
wordList.sort(key=lambda item: (len(item), item))
for i in range(len(wordList) - 1):
	if wordList[i] not in wordList[i + 1]:
		print('NO')
		quit()
print('YES')
print('\n'.join(wordList))


n = int(input())
la = []
l1 = []
for i in range(n):
	s = input()
	la.append(s)
	l1.append([len(s), i])
l1.sort()
l = []
for i in range(len(l1)):
	l.append(la[l1[i][1]])
f = 1
for i in range(n - 1):
	if l[i] not in l[i + 1]:
		f = 0
		print('NO')
		break
if f == 1:
	print('YES')
	for j in l:
		print(j)


n = int(input())
chaines = []
for i in range(n):
	chaines.append(input())
chaines.sort(key=lambda s: len(s))
marche = True
i = 0
while marche and i < n - 1:
	marche = chaines[i] in chaines[i + 1]
	i += 1
print('YES' if marche else 'NO')
if marche:
	for l in chaines:
		print(l)


n = int(input())
l = []
nn = n
while n:
	n -= 1
	s = input()
	l.append([len(s), s])
l.sort()
ch = 1
i = 1
ans = []
for i in range(nn - 1):
	if l[i][1] not in l[i + 1][1]:
		ch = 0
		break
	else:
		ans.append(l[i][1])
if ch:
	ans.append(l[nn - 1][1])
	print('YES')
	print(*ans, sep='\n')
else:
	print('NO')


n = int(input())
dct = list()
for i in range(0, n):
	st = input()
	dct.append((st, len(st)))
if n == 1:
	print('YES')
	print(dct[0][0])
	exit()
dct = sorted(dct, key=lambda pair: pair[1])
for i in range(0, n - 1):
	if dct[i][0] not in dct[i + 1][0]:
		print('NO')
		exit()
print('YES')
for i in range(0, n):
	print(dct[i][0])


from collections import *
n = int(input())
r = []
flag = 0
for i in range(n):
	a = input()
	r.append(a)
r = sorted(r, key=len)
for i in range(n - 1):
	if r[i] in r[i + 1]:
		continue
	flag = 1
	break
if flag == 0:
	print('YES')
	for i in r:
		print(i)
else:
	print('NO')


n = int(input().strip())
strings = []
for i in range(n):
	strings.append(input().strip())
uniq_len = set()
for s in strings:
	uniq_len.add(len(s))
uniq_len = list(uniq_len)
uniq_len.sort()
sorted_strings = []
for ul in uniq_len:
	for s in strings:
		if len(s) == ul:
			sorted_strings.append(s)

def check():
	global sorted_strings
	for i in range(len(sorted_strings)):
		main = sorted_strings[i]
		for j in range(i):
			sub = sorted_strings[j]
			if main.find(sub) == -1:
				print('NO')
				return
	print('YES')
	for s in sorted_strings:
		print(s)
	return
check()


n = int(input())
l = [input() for _ in range(n)]
z = l[:]
z.sort(key=lambda x: len(x))
f = 1
for i in range(1, n):
	if all((z[j] in z[i] for j in range(i))):
		pass
	else:
		f = 0
		break
if f == 0:
	print('NO')
else:
	print('YES')
	for i in z:
		print(i)


n = eval(input())
list = []
for i in range(n):
	list.append(input())
substrings = sorted(list, key=len)
if len(substrings) == 1:
	print('YES')
	for string in substrings:
		print(string)
for i in range(n - 1):
	if substrings[i] in substrings[i + 1]:
		if i == len(substrings) - 2:
			print('YES')
			for string in substrings:
				print(string)
		else:
			continue
	else:
		print('NO')
		break


def main():
	n = int(input())
	arr = sorted([input() for _ in range(n)], key=len)
	for i in range(1, n):
		if arr[i - 1] not in arr[i]:
			print('NO')
			return
	print('YES')
	print(*[x for x in arr], sep='\n')
main()


N = int(input())
A = []
for i in range(N):
	A.append(input())
B = sorted(A, key=lambda x: len(x))
val = 0
for i in range(len(B) - 1):
	for j in range(i + 1, len(B)):
		if B[i] not in B[j]:
			val = 1
			print('NO')
			break
	if val == 1:
		break
if val == 0:
	print('YES')
	for i in range(len(B)):
		print(B[i])


def Sorting(lst):
	lst2 = sorted(lst, key=len)
	return lst2
n = int(input())
array = [''] * n
for i in range(n):
	array[i] = input()
array = Sorting(array)
flag = 0
for i in range(n - 1):
	if (array[i] in array[i + 1]) == False:
		print('NO')
		flag = 1
		break
if flag == 0:
	print('YES')
	for x in array:
		print(x)


n = int(input())
l = []
ans = []
for i in range(n):
	s = input()
	l.append(s)
l.sort(key=len)
count = 0
for i in range(n):
	count = 0
	for j in range(n):
		if l[i] in l[j]:
			count += 1
	if count >= n - i:
		ans.append(l[i])
if len(ans) == n:
	print('YES')
	for i in ans:
		print(i)
else:
	print('NO')


list = []
for i in range(int(input())):
	list.append(str(input()))
nl = sorted(list, key=len)
ans = 'YES'
for i in range(len(nl) - 1):
	if nl[i] not in nl[i + 1]:
		ans = 'NO'
print(ans)
if ans == 'YES':
	print(*nl, sep='\n')


n = int(input())
strings = []
fg = True
for _ in range(n):
	strings.append(input())
strings.sort(key=len)
for i in range(n - 1):
	if len(strings[i]) == len(strings[i + 1]) and strings[i] != strings[i + 1]:
		fg = False
		print('NO')
		break
	if len(strings[i]) < len(strings[i + 1]) and strings[i] not in strings[i + 1]:
		fg = False
		print('NO')
		break
if fg:
	print('YES')
	for s in strings:
		print(s)


def F(L, n):
	for i in range(n - 1):
		for j in range(i + 1, n):
			(s, t) = (L[i], L[j])
			if not (s in t or t in s):
				print('NO')
				return
			if len(s) > len(t) or (len(s) == len(t) and s > t):
				(L[i], L[j]) = (L[j], L[i])
	print('YES')
	print(*L, sep='\n')
n = int(input())
L = [input() for i in range(n)]
F(L, n)


import functools
n = int(input())
strs = [input() for _ in range(n)]

def mycmp(x, y):
	return 0 if x == y else -1 if x in y else 1
strs.sort(key=functools.cmp_to_key(mycmp))
good = True
for i in range(n - 1):
	if mycmp(strs[i], strs[i + 1]) > 0:
		good = False
if good:
	print('YES')
	for s in strs:
		print(s)
else:
	print('NO')


__file__ = __file__.startswith('/home/a_farazei')

def input_():
	global __file__
	if not __file__:
		return input()
	if not hasattr(__file__, 'readline'):
		__file__ = open('input.txt', 'r')
	return __file__.readline()
n = int(input_())
strs = []
for _ in range(n):
	strs.append(input_().strip())
strs = sorted(strs, key=lambda x: len(x))
for (i, x) in enumerate(strs):
	for y in strs[i + 1:]:
		if x not in y:
			print('NO')
			exit()
print('YES')
for x in strs:
	print(x)


n = int(input())
a = []
for i in range(n):
	a.append(str(input()))
for i in range(n):
	for j in range(i + 1, n):
		if len(a[i]) > len(a[j]):
			(a[i], a[j]) = (a[j], a[i])
flag = True
for i in range(n - 1):
	if a[i] in a[i + 1]:
		flag = True
		continue
	else:
		print('NO')
		flag = False
		break
if flag:
	print('YES')
	for i in a:
		print(i)


N = int(input())
L = []
for i in range(0, N):
	S = input()
	L.append(S)
L = sorted(L, key=len)
j = 0
for i in range(1, N):
	if L[i].find(L[i - 1]) == -1:
		j = 1
		break
	else:
		j = 0
if j == 1:
	print('NO')
else:
	print('YES')
	for i in range(0, N):
		print(L[i])


n = int(input())
l = []
for i in range(n):
	x = input('')
	try:
		l.append(int(x))
	except ValueError:
		l.append(x)
l.sort(key=lambda s: len(s))
co = 0
for i in range(0, len(l) - 1):
	if l[i] in l[i + 1]:
		co = co + 1
if co == n - 1:
	print('YES')
	for i in range(0, len(l)):
		print(l[i])
else:
	print('NO')


n = int(input())
x = []
for i in range(n):
	x.append(input())
for i in range(n):
	for j in range(0, n - i - 1):
		if len(x[j]) > len(x[j + 1]):
			(x[j], x[j + 1]) = (x[j + 1], x[j])
for i in range(n - 1):
	if len(x[i]) == len(x[i + 1]):
		if x[i] != x[i + 1]:
			print('NO')
			exit()
for i in range(n - 1):
	if x[i] in x[i + 1]:
		x = x
	else:
		print('NO')
		exit()
print('YES')
for i in range(n):
	print(x[i])


n = int(input())
strs = list()
for i in range(n):
	strs.append(input())
sorted_strs = list()
for i in range(1, 101):
	for k in range(n):
		if len(strs[k]) == i:
			sorted_strs.append(strs[k])
possible = True
for i in range(n - 1):
	if sorted_strs[i] not in sorted_strs[i + 1]:
		possible = False
		break
if possible:
	print('YES')
	for s in sorted_strs:
		print(s)
else:
	print('NO')


import re
n = int(input())
a = list()
for i in range(0, n):
	a.append(input())
a = sorted(a, key=len)
count = 0
for i in range(1, n):
	if re.search(a[i - 1], a[i]) == None:
		count = 1
		break
if count == 0:
	print('YES')
	for i in range(0, n):
		print(a[i])
elif count == 1:
	print('NO')


n = int(input())
l = []
for i in range(n):
	l.append(str(input()))
l = sorted(l, key=len)
count = 0
for i in range(n - 1):
	if l[i] in l[i + 1]:
		count += 1
	else:
		break
if count == n - 1:
	print('YES')
	for i in l:
		print(i)
else:
	print('NO')


n = int(input())
lst = [input() for i in range(n)]
lst.sort(key=len)
for i in range(len(lst) - 1):
	if lst[i] not in lst[i + 1]:
		print('NO')
		exit()
print('YES')
for i in lst:
	print(i)


n = int(input())
li = []
for i in range(n):
	li.append(input())
li.sort(key=len, reverse=False)
q = True
for i in range(n - 1):
	if li[i] in li[i + 1]:
		pass
	else:
		q = False
		break
if q == False:
	print('NO')
else:
	print('YES')
	for ii in li:
		print(ii)


def reorder(i):
	global vector
	while i > 0:
		if vector[i] in vector[i - 1]:
			aux = vector[i]
			vector[i] = vector[i - 1]
			vector[i - 1] = aux
			i -= 1
		else:
			break

def isokay():
	global vector, n
	i = 0
	while i < n:
		j = i + 1
		while j < n:
			if vector[i] not in vector[j]:
				return False
			j += 1
		i += 1
	return True
n = int(input())
vector = [input()]
i = 1
while i < n:
	vector.append(input())
	reorder(i)
	i += 1
if isokay():
	print('YES')
	for i in vector:
		print(i)
else:
	print('NO')


import sys

def into(str1, str2):
	for i in range(len(str2) + 1 - len(str1)):
		flag1 = False
		for j in range(len(str1)):
			print(i, j)
			if str1[i + j] != str2[i + j]:
				flag1 = True
		if flag1 == True:
			continue
		else:
			return True
	return False
amount = int(input())
array = []
for i in range(amount):
	array.append(input())
sorted_array = sorted(array, key=len)
for i in range(len(sorted_array) - 1):
	if not sorted_array[i] in sorted_array[i + 1]:
		print('NO')
		sys.exit(0)
print('YES')
print('\n'.join([string for string in sorted_array]))


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()


import functools

def subs(x, y):
	if x in y:
		return -1
	elif y in x:
		return 1
	else:
		return 0
n = int(input())
l = []
for i in range(0, n):
	l.append(input())
l.sort(key=functools.cmp_to_key(subs))
for i in range(0, len(l) - 1):
	if l[i] not in l[i + 1]:
		print('NO')
		exit(0)
print('YES')
for m in l:
	print(m)


n = int(input())
list = []
for i in range(n):
	s = input()
	list.append(s)
list.sort(key=len)
flag = 0
for i in range(1, n):
	if list[i].find(list[i - 1]) == -1:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(list[i])


import random
a = int(input())
b = []
for _ in range(a):
	b.append(input())
s = [b[0]]
del b[0]
done = True
for c in b:
	done = False
	for d in range(len(s)):
		if d == 0:
			if c in s[d]:
				s = [c] + s
				done = True
		if len(s) == d + 1:
			if s[d] in c:
				s.append(c)
				done = True
		if not done:
			if s[d] in c and c in s[d + 1]:
				s.insert(d + 1, c)
				done = True
		if done:
			break
	if not done:
		print('NO')
		break
if done:
	print('YES')
	for word in s:
		print(word)


arr = sorted([input() for _ in range(int(input()))], key=len)
for i in range(len(arr) - 1):
	if not arr[i] in arr[i + 1]:
		print('NO')
		exit()
print('YES')
for s in arr:
	print(s)


n = input()
n = int(n)
i = 0
arr = []
while i < n:
	arr.append(input().strip())
	i += 1
arr = sorted(arr, key=lambda x: len(x))
i = 0
while i < n - 1:
	if arr[i] not in arr[i + 1]:
		break
	i += 1
if i == n - 1:
	print('YES')
	for ss in arr:
		print(ss)
else:
	print('NO')


n = int(input())
lista = []
for x in range(n):
	string = input()
	lista.append(string)
lista.sort()
x = 0
y = 1
resp = True
lista.sort(key=len)
while y != n:
	if lista[x] not in lista[y]:
		resp = False
		print('NO')
		break
	x += 1
	y += 1
if resp is True:
	print('YES')
	for x in lista:
		print(x)


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())
l = []
for i in range(n):
	l.append(str(input()))
l.sort(key=len)
l2 = l.copy()
l3 = []
for i in range(len(l)):
	if i < len(l) - 1:
		if l[i] in l2[i + 1]:
			l3.append(l[i])
if l[len(l) - 2] in l[len(l) - 1]:
	l3.append(l[len(l) - 1])
if len(l3) == len(l):
	print('YES')
	for i in l3:
		print(i)
else:
	print('NO')


import sys

def Sorting(lst):
	lst.sort(key=len)
	return lst
n = int(input())
l = []
for i in range(n):
	l.append(input())
if n == 1:
	print('YES')
	print(l[0])
	sys.exit()
l = Sorting(l)
count = 0
flag = False
for i in range(len(l)):
	for j in range(i + 1, len(l)):
		str = l[i]
		if l[j].count(str):
			flag = True
		else:
			flag = False
			break
	if not flag:
		break
if flag:
	print('YES')
	for i in range(len(l)):
		print(l[i])
else:
	print('NO')


numberWords = int(input())
wordList = []
for i in range(numberWords):
	wordList.append(input())
wordList.sort(key=len)
try:
	for i in range(len(wordList) - 1):
		if wordList[i] in wordList[i + 1]:
			res = 1
		else:
			res = 0
			break
	if res == 1:
		print('YES')
		for i in wordList:
			print(i)
	else:
		print('NO')
except:
	print('YES')
	for i in wordList:
		print(i)


n = int(input())
s = sorted([input() for i in range(n)], key=len)
for i in range(1, n):
	if s[i].find(s[i - 1]) == -1:
		print('NO')
		exit(0)
print('YES\n' + '\n'.join(s))


kol_str = int(input())
arr_str = []
for i in range(kol_str):
	arr_str.append(input())
for k in range(len(arr_str) - 1):
	for m in range(len(arr_str) - 1):
		if arr_str[m] not in arr_str[m + 1]:
			(arr_str[m], arr_str[m + 1]) = (arr_str[m + 1], arr_str[m])
check = 1
for n in range(kol_str - 1):
	if arr_str[n] in arr_str[n + 1]:
		check += 1
if check != kol_str:
	print('NO')
else:
	print('YES')
	for v in arr_str:
		print(v)


def main():
	n = int(input())
	a = []
	for _ in range(n):
		a.append(input())
	a = sorted(a, key=len)
	for i in range(1, n):
		if a[i - 1] in a[i]:
			pass
		else:
			print('NO')
			return
	print('YES')
	for s in a:
		print(s)
main()


n = int(input())
a = []
b = []
for k in range(n):
	t = input()
	a.append(t)
	b.append(len(t))
b.sort()
b = b[::-1]
c = []
w = 0
u = 0
for k in range(len(b)):
	for p in a:
		if len(p) == b[k]:
			if len(c) == 0:
				c.append(p)
				a.remove(p)
				t = 0
				break
			elif p not in c[t]:
				print('NO')
				u = 1
				break
			else:
				c.append(p)
				a.remove(p)
				t += 1
				break
	if u == 1:
		w = 1
		break
if w == 0:
	c = c[::-1]
	print('YES')
	for k in range(len(c)):
		print(c[k])


import sys
n = int(input())
L = []
for i in range(n):
	str = input()
	L.append(str)

def sort(s):
	return (len(s), s)
L.sort(key=sort)
for i in range(n - 1):
	if not L[i] in L[i + 1]:
		print('NO')
		sys.exit()
print('YES')
for el in L:
	print(el)


import sys

def sortVal(a):
	return len(a)
n = int(sys.stdin.readline().strip())
strList = []
for i in range(n):
	strList.append(sys.stdin.readline().strip())
strList.sort(key=sortVal)
for i in range(n - 1):
	if strList[i] not in strList[i + 1]:
		print('NO')
		sys.exit()
print('YES')
for i in range(n):
	print(strList[i])


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)


strings = [input() for i in range(int(input()))]
tupl = sorted([(len(strings[i]), strings[i]) for i in range(len(strings))])
for i in range(1, len(tupl)):
	if tupl[i - 1][1] not in tupl[i][1]:
		print('NO')
		raise SystemExit(0)
print('YES\n' + '\n'.join([t[1] for t in tupl]))


n = int(input())
khela = []
for i in range(n):
	s = input()
	khela.append([len(s), s])
khela = sorted(khela)
if n == 1:
	print('YES')
	print(khela[0][1])
else:
	lent = len(khela)
	for i in range(lent - 1):
		c = 0
		for ii in range(i + 1, khela[i + 1][0] - khela[i][0] + 2 + i):
			if khela[i][1] == khela[i + 1][1][ii - i - 1:ii + khela[i][0] - i - 1]:
				c = 1
		if c == 0:
			break
	if c == 1:
		print('YES')
		for i in range(len(khela)):
			print(khela[i][1])
	else:
		print('NO')


str_list = []
flag = True
n = int(input())
for i in range(n):
	str_list.append(input())
str_list = sorted(str_list, key=len)
for i in range(n - 1):
	if not str_list[i] in str_list[i + 1]:
		print('NO')
		flag = False
		break
if flag:
	print('YES')
	for item in str_list:
		print(item)


import os
import sys
import math
import collections
import cmath

def mp():
	return map(int, input().split())

def inp():
	return input()
d = []
flag = 0
n = int(inp())
if n == 1:
	a = inp()
	print('YES')
	print(a)
	exit()
for i in range(n):
	a = inp()
	d.append(a)
c = sorted(d, key=len)
for i in range(n - 1):
	if c[i] in c[i + 1]:
		flag = 1
	else:
		flag = 0
		break
if flag == 1:
	print('YES')
	for i in c:
		print(i)
else:
	print('NO')


n = int(input())
s = [input() for i in range(n)]
in_ = [[False for i in range(n)] for j in range(n)]
for i in range(n):
	for j in range(n):
		if i != j and s[i] in s[j]:
			in_[i][j] = True
used = [False for i in range(n)]
ans = list()
for i in range(n):
	for j in range(n):
		if used[j]:
			continue
		for k in range(n):
			if used[k]:
				continue
			if j == k:
				continue
			if in_[j][k]:
				pass
			else:
				break
		else:
			used[j] = True
			ans.append(s[j])
			break
	else:
		print('NO')
		exit()
print('YES')
print('\n'.join(ans))


n = int(input())
a = []
for i in range(n):
	s = input()
	a.append(s)
a.sort(key=len)
for i in range(n - 1):
	if a[i + 1].find(a[i]) == -1:
		print('NO')
		exit()
print('YES')
for i in range(n):
	print(a[i])


n = int(input())
a = []
for i in range(n):
	a += [input()]
b = []
for i in range(1, 101):
	for j in a:
		if len(j) == i:
			b += [j]
t = 0
for i in range(1, len(b)):
	if b[i - 1] not in b[i]:
		t = 1
		break
if t == 1:
	print('NO')
else:
	print('YES')
	for i in b:
		print(i)


import functools

def fog(a, b):
	return len(a) < len(b)
n = int(input())
a = [input() for i in range(n)]
a = sorted(a, key=len)
for i in range(n - 1):
	if a[i] in a[i + 1]:
		continue
	else:
		print('NO')
		exit()
print('YES')
for i in range(n):
	print(a[i])


X = sorted([input() for i in range(int(input()))], key=len)
for i in range(len(X) - 2, -1, -1):
	if X[i] not in X[i + 1]:
		print('NO')
		exit()
print('YES')
print(*X, sep='\n')


n = int(input())
a = []
for i in range(n):
	a.append(input())
a.sort(key=len)
coutn = 1
for i in range(1, n):
	if a[i].count(a[i - 1]) >= 1:
		coutn += 1
if coutn == len(a):
	print('YES')
	for i in range(n):
		print(a[i])
else:
	print('NO')


d = {}
n = int(input())
l = []
for i in range(n):
	l.append(input())
l.sort(key=len)
old = l[0]
for i in l:
	if old not in i:
		print('NO')
		exit()
	old = i
print('YES')
for i in l:
	print(i)


from collections import defaultdict
n = int(input())
l = []
hash = defaultdict(int)
yo = defaultdict(int)
for i in range(n):
	z = input()
	l.append(z)
	yo[z] += 1
ans = []
for i in yo:
	count = 0
	for j in yo:
		if i in j:
			count += 1
			continue
	hash[i] += count
z = len(yo)
for i in yo:
	ans.append([hash[i], i])
ans.sort(reverse=True)
new_ans = []
flag = 0
vo = z
for i in range(z):
	if ans[i][0] == vo:
		vo -= 1
		continue
	else:
		flag = 1
		break
if flag:
	print('NO')
else:
	print('YES')
	for (i, j) in ans:
		for k in range(yo[j]):
			print(j)


import sys
num_strings = int(sys.stdin.readline())
mystrings = []
data = sys.stdin.read().splitlines()
for i in data:
	mystrings.append(i)
mystrings.sort(key=lambda s: len(s))
flag = True
for i in range(len(mystrings) - 1):
	if mystrings[i] not in mystrings[i + 1]:
		flag = False
		break
if flag:
	sys.stdout.write('YES' + '\n')
	for mystring in mystrings:
		sys.stdout.write(mystring + '\n')
else:
	sys.stdout.write('NO')


from collections import defaultdict
x = int(input())
lol = []
for i in range(x):
	lol.append(input())
lol = sorted(lol, key=len)
k = lol[0]
f = 0
for i in lol:
	if k not in i:
		f = 1
		break
	k = i
if f:
	print('NO')
else:
	print('YES')
	for i in lol:
		print(i)


n = int(input())
strs = []
for i in range(n):
	strs += [input()]
count = 1
while count:
	count = 0
	for i in range(1, len(strs)):
		if strs[i] in strs[i - 1] and strs[i] != strs[i - 1]:
			(strs[i - 1], strs[i]) = (strs[i], strs[i - 1])
			count += 1
for i in range(1, len(strs)):
	if strs[i - 1] not in strs[i]:
		print('NO')
		break
else:
	print('YES')
	for i in strs:
		print(i)


n = int(input())
l = []
k = 0
for i in range(n):
	s = input()
	l.append(s)
l.sort(key=len)
l2 = []
for i in range(n):
	s3 = str(l[i])
	l2.append(s3)
c = 0
for i in range(len(l2) - 1):
	s2 = str(l2[i])
	s3 = str(l2[i + 1])
	if s2 not in s3:
		c = 1
		break
if c == 0:
	print('YES')
	for i in l2:
		print(i)
else:
	print('NO')


def comp(arr):
	for i in range(len(arr) - 1):
		for j in range(0, len(arr) - i - 1):
			if arr[j] in arr[j + 1]:
				(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
	return arr[::-1]
t = int(input())
ans = 1
arr = []
for j in range(t):
	arr.append(input())
arr = comp(arr)
for j in range(0, t - 1):
	if arr[j] not in arr[j + 1]:
		ans = 0
		break
if ans == 0:
	print('NO')
else:
	print('YES')
	for j in arr:
		print(j)


def check(strings):
	for i in range(len(strings) - 1):
		if strings[i] not in strings[i + 1]:
			return False
	return True
n = int(input())
a = []
for _ in range(n):
	a.append(input())
a.sort(key=lambda x: len(x))
if check(a):
	print('YES')
	print(*a, sep='\n')
	exit(0)
print('NO')


import sys

def main():
	NumStr = int(input())
	Strings = []
	for i in range(0, NumStr):
		Strings.append(input())
	Sorted_Strings = sorted(Strings, key=len)
	for (i, string) in enumerate(Sorted_Strings):
		pass
		for left_str in Sorted_Strings[:i]:
			if left_str not in string:
				print('NO')
				return
	print('YES')
	for strings in Sorted_Strings:
		print(strings)
main()


import string
n = int(input())
li = []
i = 0
while i != n:
	li.append(input())
	i = i + 1
i = 0
while i != n:
	j = 0
	i = i + 1
	while j != n - 1:
		if li[j].find(li[j + 1]) >= 0:
			s = li[j]
			li[j] = li[j + 1]
			li[j + 1] = s
		j = j + 1
flag = 1
i = n - 1
while i > 0:
	if li[i].find(li[i - 1]) < 0:
		flag = 0
		i = 0
	i = i - 1
if flag == 1:
	print('YES')
	i = 0
	while i != n:
		print(li[i])
		i = i + 1
else:
	print('NO')


n = int(input())
list2 = []
for i in range(n):
	list2.append(input())
list2.sort(key=len)
i = 0
c = 0
list3 = []
while i + 1 != n:
	p = list2[i + 1].find(list2[i])
	if p == -1:
		print('NO')
		c = 1
		break
	else:
		list3.append(list2[i])
	i = i + 1
if c == 0:
	list3.append(list2[n - 1])
	print('YES')
	for i in range(n):
		print(list3[i])


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')
	exit()
print('YES\n%s' % '\n'.join(src))


n = int(input())
s = sorted((input() for i in range(n)), key=len)
v = all((s[i] in s[i + 1] for i in range(n - 1)))
print('YES\n' + '\n'.join(s) if v else 'NO')


a = int(input())
l = []
for i in range(a):
	pal = input()
	l.append([len(pal), pal])
l.sort()
ok = True
for i in range(1, len(l)):
	if l[i - 1][1] not in l[i][1]:
		ok = False
if ok:
	print('YES')
	for i in l:
		print(i[1])
else:
	print('NO')


def c_key(s):
	return len(s)
n = int(input())
mass = []
for i in range(n):
	mass.append(input())
mass = sorted(mass, key=c_key)
flag = True
for i in range(n):
	for j in range(i + 1, n):
		if mass[i] not in mass[j]:
			flag = False
			break
		if flag == False:
			break
if flag == False:
	print('NO')
else:
	print('YES')
	for i in range(len(mass)):
		print(mass[i])


T = int(input())
arr = []
for i in range(0, T):
	a = input()
	arr.append(a)
arr.sort(key=len)
flag = 1
for i in range(1, T):
	if arr[i].find(arr[i - 1]) == -1:
		flag = 0
		break
if flag == 0:
	print('NO')
else:
	print('YES')
	for i in range(0, T):
		print(arr[i])


def cmp(a):
	return len(a)
n = int(input())
v = [''] * n
for i in range(n):
	v[i] = input()
v = sorted(v, key=cmp)
ans = True
for i in range(n - 1):
	sf = v[i]
	sl = v[i + 1]
	flag = False
	for j in range(len(sl) - len(sf) + 1):
		if sl[j:j + len(sf)] == sf:
			flag = True
			break
	if not flag:
		ans = False
		break
if ans:
	print('YES')
	for i in range(n):
		print(v[i])
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)


def isa(a, b):
	for i in range(len(b) - len(a) + 1):
		if b[i:i + len(a)] == a:
			return True
	return False
n = int(input())
a = []
for i in range(n):
	k = input()
	i = 0
	while i < len(a) and len(k) > len(a[i]):
		i += 1
	a.insert(i, k)
for i in range(n - 1):
	if not isa(a[i], a[i + 1]):
		print('NO')
		break
if n == 1:
	print('YES')
	print(a[0])
elif isa(a[i], a[i + 1]):
	print('YES')
	for i in range(n):
		print(a[i])


n = int(input())
strings = []
for _ in range(n):
	x = input()
	strings.append([len(x), x])
strings.sort()
result = 'YES'
for i in range(n - 1):
	if strings[i][1] not in strings[i + 1][1]:
		result = 'NO'
print(result)
if result == 'YES':
	for x in strings:
		print(x[1])


l = [input() for i in range(int(input()))]
l.sort(key=len)
j = 0
for i in range(len(l) - 1):
	if l[i] in l[i + 1]:
		pass
	else:
		j = 1
		break
if j == 1:
	print('NO')
else:
	print('YES')
	for i in l:
		print(i)


n = int(input())
q = [str(x) for _ in range(n) for x in input().split()]
q.sort(key=lambda x: [len(x)])
flag = 1
for i in range(n - 1):
	if q[i] not in q[i + 1]:
		flag = 0
		break
print('YES' if flag else 'NO')
if flag:
	for x in q:
		print(x)


n = int(input())
L = []
for i in range(n):
	x = str(input())
	L.append(x)
L.sort(key=len)
B = True
for i in range(len(L)):
	for k in range(i):
		B = L[k] in L[i]
		if B == False:
			break
	if B == False:
		break
if B == True:
	print('YES')
	print('\n'.join(L))
else:
	print('NO')


n = int(input())
strs = [input() for _ in range(n)]
strs.sort(key=len)
for i in range(n - 1, 0, -1):
	if strs[i].find(strs[i - 1]) == -1:
		print('NO')
		exit(0)
print('YES')
print('\n'.join(strs))


def takeLength(elem):
	return len(elem)
n = int(input())
a = []
flag = 0
for i in range(n):
	a.append(input())
a.sort(key=takeLength)
for (i, j) in zip(a, a[1:]):
	if (i in j) == False:
		flag = 1
print('YES' if flag == 0 else 'NO')
if flag == 0:
	for i in a:
		print(i)


n = int(input())
listik = []
for i in range(n):
	line = input()
	listik.append(line)
listik = listik
for i in range(n - 1):
	for j in range(n - 1 - i):
		if listik[j] not in listik[j + 1]:
			(listik[j], listik[j + 1]) = (listik[j + 1], listik[j])
for i in range(n - 1):
	if listik[i] not in listik[i + 1]:
		print('NO')
		break
	elif i == n - 2:
		print('YES')
		for i in listik:
			print(i)
if n == 1:
	print('YES')
	print(listik[0])


n = int(input())
l = []
r = []
for _ in range(n):
	l.append(str(input()))
ss = ''
for _ in range(n):
	ns = ''
	for word in l:
		if ss in word:
			if ns == '' or len(word) < len(ns):
				ns = word
	if ns != '':
		r.append(ns)
		l.remove(ns)
		ss = ns
	else:
		break
if l:
	print('NO')
else:
	print('YES')
	for word in r:
		print(word)


n = int(input())
l = []
for i in range(n):
	l.append(input())
l.sort(key=len)
k = l[-1]
f = True
for i in range(n - 1):
	if l[i] not in l[i + 1] or l[i] not in k:
		f = False
		break
if f:
	print('YES')
	print(*l, sep='\n')
else:
	print('NO')


def main():
	n = int(input())
	seq = list()
	for _ in range(n):
		seq.append(input())
	seq.sort(key=lambda x: len(x))
	for i in range(len(seq) - 1):
		if seq[i] not in seq[i + 1]:
			print('NO', end='')
			exit()
	print('YES', end='')
	for x in seq:
		print(f'\n{x}', end='')
main()


def solve(words):
	words.sort(key=lambda a: len(a))
	for i in range(1, len(words)):
		if words[i].find(words[i - 1]) == -1:
			print('NO')
			return
	print('YES')
	for word in words:
		print(word)
n = int(input())
words = []
for _ in range(n):
	words.append(input())
solve(words)


n = int(input())
a = []
for i in range(n):
	a.append(input())
a = sorted(a, key=lambda x: len(x))
res = []
for i in range(n - 1):
	if a[i] in a[i + 1]:
		res.append(a[i])
	else:
		break
if len(res) == n - 1:
	print('YES')
	res.append(a[-1])
	print(*res, sep='\n')
else:
	print('NO')


n = int(input())
S = []
for i in range(n):
	x = input()
	S.append([x, len(x)])
S.sort(key=lambda x: x[1], reverse=True)
F = 'YES'
for i in range(n):
	for j in range(i + 1, n):
		if S[i][0].count(S[j][0]) < 1:
			F = 'NO'
			break
S = S[::-1]
print(F)
if F == 'YES':
	for x in S:
		print(x[0])


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
arr = sorted(arr, key=len)
x = 0
for i in range(n - 1):
	if arr[i] in arr[i + 1]:
		pass
	else:
		x = 1
if x == 1:
	print('NO')
else:
	print('YES')
	print(*arr, sep='\n')


n = int(input())
lines = []
for i in range(n):
	lines.append(input())
lines = sorted(lines, key=lambda x: len(x))
contains = True
for i in range(n - 1):
	if not lines[i] in lines[i + 1]:
		contains = False
		break
if contains:
	print('YES')
	for line in lines:
		print(line)
else:
	print('NO')


n = int(input())
h = []
for i in range(n):
	h.append(input())
h.sort(key=lambda s: len(s))
ans = 'YES'
for i in range(0, n - 1):
	if h[i] not in h[i + 1]:
		ans = 'NO'
print(ans)
if ans is 'YES':
	for i in h:
		print(i)


def insert(strarr, st):
	i = 0
	while i < len(strarr):
		if len(st) < len(strarr[i]):
			return strarr[:i] + [st] + strarr[i:]
		i += 1
	return strarr + [st]

def is_substr(sub, parent):
	for j in range(len(parent) - len(sub) + 1):
		for i in range(len(sub)):
			if sub[i] != parent[j + i]:
				break
			if i == len(sub) - 1:
				return True
	return False
n = int(input())
st = []
for _ in range(n):
	st = insert(st, input())
ret = True
for i in range(n - 1):
	if not is_substr(st[i], st[i + 1]):
		ret = False
		break
if ret:
	print('YES')
	for s in st:
		print(s)
else:
	print('NO')


n = int(input())
strings = [input() for _ in range(n)]
strings.sort(key=len)
for (a, b) in zip(strings, strings[1:]):
	if a not in b:
		print('NO')
		break
else:
	print('YES')
	for s in strings:
		print(s)


n = int(input())
l = []
for i in range(n):
	ele = input()
	l.append(ele)
for i in range(len(l)):
	for j in range(len(l) - 1 - i):
		if len(l[j]) > len(l[j + 1]):
			(l[j], l[j + 1]) = (l[j + 1], l[j])
new = []
i = 0
for s in range(len(l)):
	temp = 0
	for single in l[s:]:
		if l[s] in single:
			temp += 1
	if temp == len(l) - s:
		new.append(l[s])
if new == l:
	print('YES')
	for i in new:
		print(i)
else:
	print('NO')


n = int(input())
l = []
for i in range(n):
	l.append(input())
l = sorted(l, key=lambda x: len(x))
tr = False
for i in range(1, n):
	if l[i - 1] not in l[i]:
		tr = True
if tr == True:
	print('NO')
else:
	print('YES')
	for i in l:
		print(i)


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


n = int(input())
be = []
for i in range(n):
	bemenet = input()
	be.append((len(bemenet), bemenet))
be.sort()
r = False
for s in range(n):
	try:
		if be[s][1] in be[s + 1][1]:
			continue
		r = True
	except IndexError:
		continue
if r:
	print('NO')
else:
	print('YES')
	for i in be:
		print(i[1])


import sys
n = int(input())
b = []
for i in range(n):
	b.append(input())
b.sort(key=len)
for i in range(n - 1):
	if b[i] not in b[i + 1]:
		print('NO')
		sys.exit()
print('YES')
for string in b:
	print(string)


n = int(input())
p = []
count = 0
for i in range(n):
	__ = input()
	p.append(__)
p = sorted(p, key=len)
if len(p) == 1:
	print('YES')
	for i in p:
		print(i)
	exit()
c = 1
longest = p[c]
for i in p:
	if longest.find(i) == -1:
		count += 1
	c += 1
	if c >= len(p):
		break
	else:
		longest = p[c]
if count == 0:
	print('YES')
	for i in p:
		print(i)
else:
	print('NO')


n = int(input())
a = []
i = 0
for i in range(n):
	a.append(input())
a.sort(key=len)
flag = 0
for my_str in a:
	for str in a[a.index(my_str):]:
		if str.find(my_str) == -1:
			flag = 1
	if flag == 1:
		print('NO')
		break
if flag == 0:
	print('YES')
	for i in a:
		print(i)


s = []
for i in range(int(input())):
	s.append(input())
s = sorted(s, key=lambda p: len(p))
cnt = 0
for i in range(len(s) - 1):
	if s[i] not in s[i + 1]:
		cnt = 1
		break
if cnt == 0:
	print('YES')
	for i in range(len(s)):
		print(s[i])
else:
	print('NO')


n = int(input())

def why(s1: str, s2: str) -> bool:
	if s1.find(s2, 0, len(s1)) != -1:
		return s2 < s1
	elif s2.find(s1, 0, len(s2)) != -1:
		return s1 < s2
	else:
		return s1 == s2
All = []
for i in range(n):
	All.append(input())
All.sort(key=len)
flag = True
for i in range(n - 1):
	if All[i + 1].find(All[i], 0, len(All[i + 1])) == -1:
		flag = False
		break
if flag:
	print('YES')
	for i in range(n):
		print(All[i])
else:
	print('NO')


n = int(input())
l = []
for _ in range(n):
	s = input()
	l.append([len(s), s])
l.sort()
c = 0
for i in range(n - 1):
	res = l[i + 1][1].find(l[i][1])
	if res == -1:
		c = 1
		break
if c == 1:
	print('NO')
else:
	print('YES')
	for i in range(len(l)):
		print(l[i][1])


def calc(n, a):
	flag = 0
	for i in range(n):
		for j in range(n - 1 - i):
			if len(a[j + 1]) < len(a[j]):
				(a[j + 1], a[j]) = (a[j], a[j + 1])
	for i in range(n):
		for j in range(i + 1, n):
			if a[i] not in a[j]:
				flag = 1
				break
	if flag == 1:
		print('NO')
		return
	else:
		print('YES')
		for i in a:
			print(i)
n = int(input())
a = []
for i in range(n):
	a.append(input())
calc(n, a)


n = int(input())
strings = []
for i in range(n):
	strings.append(input())
strings = sorted(strings, key=lambda x: len(x))
res = True
for i in range(1, len(strings)):
	if strings[i - 1] in strings[i]:
		continue
	else:
		res = False
if res:
	print('YES')
	for i in strings:
		print(i)
else:
	print('NO')


def sorter(l):
	flag = 0
	while flag == 0:
		flag = 1
		for i in range(0, len(l) - 1):
			if len(l[i]) > len(l[i + 1]):
				temp = l[i]
				l[i] = l[i + 1]
				l[i + 1] = temp
				flag = 0
n = int(input())
strings = []
for i in range(0, n):
	strings += [str(input())]
sorter(strings)
flag = 1
for i in range(0, n - 1):
	if strings[i] not in strings[i + 1]:
		flag = 0
if flag == 0:
	print('NO')
else:
	print('YES')
	for i in strings:
		print(i)


def check(arr):
	for i in range(1, len(arr)):
		if arr[i][0] == len(arr[i - 1][1]):
			if arr[i][1] != arr[i - 1][1]:
				return False
		elif arr[i - 1][1] not in arr[i][1]:
			return False
	return True
a = []
for nt in range(int(input())):
	s = input()
	a.append((len(s), s))
a.sort()
if check(a):
	print('YES')
	for i in a:
		print(i[1])
else:
	print('NO')


n = int(input())
p = []
for i in range(n):
	s = input()
	p.append(s)
q = sorted(p, key=len)
a = 0
for i in range(1, len(q)):
	if q[i].find(q[i - 1]) == -1:
		a = 1
		break
if a == 1:
	print('NO')
else:
	print('YES')
	for i in range(len(q)):
		print(q[i])


def check_substr(a, b):
	if a in b:
		return True
	else:
		return False

def substring_sort(strings):
	strings_new = set(strings)
	strings_new = sorted(strings, key=len)
	i = len(strings_new) - 2
	while i >= 0:
		result = check_substr(strings_new[i], strings_new[i + 1])
		if not result:
			print('NO')
			return
		i -= 1
	print('YES')
	res = sorted(strings, key=len)
	for c in res:
		print(c)
n = int(input())
strs = []
while n > 0:
	inp_str = input()
	strs.append(inp_str)
	n -= 1
substring_sort(strs)


n = int(input())
u = []
for i in range(n):
	u.append(input())
u.sort(key=len)
ans = 'YES'
k = 0
for i in range(1, n):
	k = u[i].find(u[i - 1])
	if k == -1:
		ans = 'NO'
		break
print(ans)
if k != -1:
	for i in u:
		print(i)


n = int(input())
s = []
for i in range(n):
	p = ''
	p = input()
	s = s + [p]
count = []
l = []
dic = {}
for i in s:
	flag = 0
	for j in s:
		if i in j:
			flag += 1
	count += [flag]
	if flag not in l:
		dic[flag] = [i]
		l += [flag]
	else:
		dic[flag] += [i]
count.sort()
tmp = 1
for i in range(n):
	if count[i] < i + 1:
		tmp = 0
if tmp == 1:
	print('YES')
	l.sort()
	l.reverse()
	for i in l:
		for j in dic[i]:
			print(j)
else:
	print('NO')


n = int(input())
a = []
ans = 'YES'
for i in range(n):
	a.append(input())
a.sort(key=lambda x: len(x))
i = 0
while ans != 'NO' and i != n - 1:
	if a[i + 1].find(a[i]) == -1:
		ans = 'NO'
	i += 1
print(ans)
if ans == 'YES':
	for item in a:
		print(item)


n = int(input())
m = []
for i in range(n):
	c = input()
	m.append((c, len(c)))
m.sort(key=lambda x: x[1])
i = 0
while i < n - 1:
	if m[i][0] in m[i + 1][0]:
		i += 1
	else:
		i = n
if i == n - 1:
	print('YES')
	for j in range(n):
		print(m[j][0])
else:
	print('NO')


import collections

class Solution:

	def solve(self, n, strings):
		strings = sorted(strings, key=lambda x: len(x))
		for i in range(n - 1):
			first = strings[i]
			second = strings[i + 1]
			if second.find(first) == -1:
				return (False, None)
		return (True, strings)
sol = Solution()
n = int(input().strip())
strings = []
for i in range(n):
	string = input().strip()
	strings.append(string)
(ans, strings) = sol.solve(n, strings)
if ans:
	print('YES')
	print('\n'.join(strings))
else:
	print('NO')


def main():
	n = int(input())
	res = [input() for _ in range(n)]
	res.sort(key=len)
	prev = ''
	for cur in res:
		if prev not in cur:
			print('NO')
			return
		prev = cur
	print('YES')
	for s in res:
		print(s)
main()


n = int(input())
s = []
for i in range(n):
	s.append(input())
s = sorted(s, key=len)
k = 1
for i in range(len(s) - 1):
	if s[i] in s[i + 1]:
		k += 1
if k == n:
	print('YES')
	for i in range(n):
		print(s[i])
else:
	print('NO')


n = int(input())
a = {}
for i in range(n):
	b = input()
	l = len(b)
	if l in a:
		a[l].append(b)
	else:
		a[l] = [b]
a = sorted(zip(a.keys(), a.values()))
a = list(zip(*a))
a = a[1]
b = []
for i in a:
	for j in i:
		b.append(j)
(k, p) = (b[0], 0)
for i in range(1, n):
	if b[i].find(k) == -1:
		p = p + 1
		break
	k = b[i]
if p == 0:
	print('YES')
	for i in b:
		print(i)
else:
	print('NO')


def custom_key(str):
	return len(str)
n = eval(input())
list = []
for i in range(0, n):
	list.append(input())
result = sorted(list, key=custom_key)
for i in range(0, n - 1):
	if result[i + 1].find(result[i]) == -1:
		print('NO')
		exit()
print('YES')
for s in result:
	print(s)


import io
import os

def solve():
	n = int(input())
	strings = [input() for _ in range(n)]
	strings.sort(key=lambda s: len(s))
	for (s1, s2) in zip(strings, strings[1:]):
		if not s1 in s2:
			print('NO')
			return
	print('YES')
	for s in strings:
		print(s)
solve()


n = int(input())
l = []
for i in range(n):
	l.append(input())
l = sorted(l, key=lambda w: len(w))
for i in range(len(l) - 1):
	if l[i] not in l[i + 1]:
		print('NO')
		exit()
print('YES')
for i in l:
	print(i)


n = int(input())
a = []
for _ in range(n):
	a.append(input())
a.sort(key=len)
if all(map(lambda c, s: c in s, a, a[1:])):
	print('YES')
	print(*a, sep='\n')
else:
	print('NO')


n = int(input())
l = []
q = []
w = []
S = []
D = []
G = 0
C = 1
O = 0
for i in range(0, n):
	s = input().rstrip()
	l.append(len(list(s)))
	q.append(s)
while 1:
	if len(l) == 0:
		O = 1
		break
	t = min(l)
	f = l.index(t)
	A = list(q[f])
	del l[f]
	del q[f]
	if G == 0:
		G = 1
		S.append(A)
	else:
		B = S[len(S) - 1]
		H = 0
		for i in range(0, len(A) - len(B) + 1):
			t = A[i:i + len(B)]
			if ''.join(t) == ''.join(B):
				H = 1
				break
		if H == 1:
			S.append(A)
		else:
			C = 0
			break
if C == 0:
	print('NO')
else:
	print('YES')
	for i in range(0, len(S)):
		print(''.join(S[i]))


n = int(input())
arr = [input() for i in range(n)]
arr = [ii[1] for ii in sorted([[len(i), i] for i in arr])]
for i in range(1, n):
	if len(arr[i]) == len(arr[i - 1]):
		if arr[i] != arr[i - 1]:
			print('NO')
			exit()
		else:
			continue
	if len(arr[i].split(arr[i - 1])) == 1:
		print('NO')
		exit()
print('YES')
print('\n'.join(arr))


n = int(input())
strings = [input() for i in range(n)]
strings.sort(reverse=1, key=lambda x: (len(x), x))
answer = [strings[0]]
del strings[0]
while len(strings) != 0:
	now = strings[0]
	del strings[0]
	if now in answer[-1]:
		answer.append(now)
	else:
		print('NO')
		exit(0)
if len(answer) != n:
	print('NO')
else:
	print('YES')
	for i in reversed(answer):
		print(i)


n = int(input())
num = n
lst = []
while n > 0:
	temp = input()
	lst.append((len(temp), temp))
	n -= 1
lst.sort(reverse=True)
answer = []
flag = True
i = 1
for i in range(1, num):
	if lst[i][1] in lst[i - 1][1]:
		answer.append(lst[i - 1][1])
	else:
		flag = False
		break
if flag == True:
	answer.append(lst[-1][1])
if flag != True:
	print('NO')
else:
	print('YES')
	while len(answer) != 0:
		print(answer.pop())


import sys
data = sys.stdin.readlines()
lis = []
for line in data:
	lis.append(line)

def is_substring(a, b):
	aLngth = len(a)
	bLngth = len(b)
	diff = bLngth - aLngth
	if aLngth > bLngth:
		return Flase
	for i in range(diff + 1):
		if b[i:i + aLngth] == a:
			return True
	return False

def remove_line(a):
	if a[-1] == '\n':
		return a[:-1]
	else:
		return a
n = int(lis[0])
lis.pop(0)
lis = list(map(remove_line, lis))
lis.sort(key=lambda x: len(x))
for i in range(n - 1):
	if not is_substring(lis[i], lis[i + 1]):
		print('NO')
		sys.exit()
print('YES')
for word in lis:
	print(word)


a = []
b = []
n = int(input())
for i in range(n):
	a.append(input())
flag = 0
for i in range(n):
	for j in range(n):
		if a[i] in a[j]:
			temp = a[i]
			a[i] = a[j]
			a[j] = temp
for i in range(n):
	for j in range(i + 1, n):
		if a[i] not in a[j]:
			flag = 1
			break
	if flag:
		break
if flag:
	print('NO')
else:
	print('YES')
	for i in a:
		print(i)


n = int(input(''))
slarray = list()
for i in range(0, n):
	x = input('')
	slarray.append((x, len(x)))
slarray = sorted(slarray, key=lambda x: x[1], reverse=False)
for i in range(0, n - 1):
	if slarray[i][0] not in slarray[i + 1][0]:
		print('NO')
		quit()
print('YES')
for pr in slarray:
	print(pr[0])


def sorting_substring(seq):
	seq.sort()
	seq.sort(key=len)
	index = 1
	while index < len(seq):
		if seq[index - 1] not in seq[index]:
			print('NO')
			return
		index += 1
	print('YES')
	print('\n'.join(seq))
n = int(input())
seq = []
for x in range(n):
	seq.append(input())
sorting_substring(seq)


def cmp(val):
	return len(val)

def run_code():
	n = int(input())
	arr = []
	for i in range(n):
		arr.append(input())
	arr.sort(key=cmp)
	flag = True
	for i in range(1, len(arr)):
		if arr[i - 1] not in arr[i]:
			flag = False
			break
	if flag:
		print('YES')
		for i in range(len(arr)):
			print(arr[i])
	else:
		print('NO')
run_code()


import sys
n = int(input())
i = 0
s = []
while i < n:
	s.append(input())
	i += 1
s.sort(key=lambda x: (len(x), x.lower()))
for (i, value) in enumerate(s):
	for j in s[i + 1:]:
		index = j.find(value)
		if index == -1:
			print('NO')
			sys.exit()
print('YES')
for i in s:
	print(i)


n = int(input())
arr = []
for k in range(n):
	string = str(input())
	arr.append(string)
for i in range(0, len(arr)):
	for j in range(i + 1, len(arr)):
		if len(arr[j]) < len(arr[i]):
			(arr[j], arr[i]) = (arr[i], arr[j])
if len(arr) == 1:
	print('YES')
	for stri in arr:
		print(stri)
else:
	for k in range(len(arr) - 1):
		if arr[k] in arr[k + 1]:
			if k == len(arr) - 2:
				print('YES')
				for stri in arr:
					print(stri)
		else:
			print('NO')
			break


def substring_sort():
	k = int(input())
	team = []
	for i in range(k):
		sub = input()
		team.append(sub)
	team.sort(key=len)
	for i in range(k - 1):
		if team[i] not in team[i + 1]:
			print('NO')
			return
	print('YES')
	print('\n'.join(team))
	return
substring_sort()


n = eval(input())
count = 1
string = []
for i in range(0, n):
	a = input()
	string.append(a)

def sort(b):
	for i in range(0, n):
		if i < n - 1:
			if len(b[i]) > len(b[i + 1]):
				(b[i], b[i + 1]) = (b[i + 1], b[i])
for i in range(0, n):
	sort(string)
for i in range(0, n):
	if i < n - 1:
		if string[i] in string[i + 1]:
			count += 1
if count == n:
	print('YES')
	for i in range(0, n):
		print(string[i])
else:
	print('NO')


n = int(input())
rec = [[] for i in range(101)]
for i in range(n):
	s = input()
	rec[len(s)].append(s)
q = []
for i in rec:
	if len(i) > 0:
		q += sorted(i)
pre = q[0]
flag = True
for i in range(1, n):
	flag2 = False
	if len(pre) == len(q[i]):
		if pre == q[i]:
			flag2 = True
	else:
		for j in range(len(q[i]) - len(pre) + 1):
			if pre == q[i][j:j + len(pre)]:
				flag2 = True
				break
	if not flag2:
		flag = False
		break
	pre = q[i]
if flag:
	print('YES')
	for i in range(len(q)):
		print(q[i])
else:
	print('NO')


import sys
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')
for _ in range(1):
	n = int(input())
	l = []
	for i in range(n):
		l.append(input())
	for i in range(n):
		for j in range(n - 1):
			if len(l[j + 1]) < len(l[j]):
				(l[j], l[j + 1]) = (l[j + 1], l[j])
	f = True
	for i in range(n - 1):
		if l[i] not in l[i + 1]:
			f = False
			break
	if f:
		print('YES')
		for i in l:
			print(i)
	else:
		print('NO')


n = int(input())
s = [input() for i in range(n)]
s.sort(key=len)
c = True
for i in range(n - 1):
	if s[i] not in s[i + 1]:
		c = False
		break
if c:
	print('YES')
	for i in s:
		print(i)
else:
	print('NO')


n = int(input())
s = []
for i in range(n):
	s.append(input())
s.sort(key=lambda x: len(x))
possible = True
for i in range(n):
	for j in range(i + 1, n):
		if s[i] not in s[j]:
			possible = False
if possible:
	print('YES')
	for i in range(n):
		print(s[i])
else:
	print('NO')


def question2():
	N = int(input())
	arr = []
	for i in range(N):
		a1 = input()
		arr.append([a1, len(a1)])
	arr.sort(key=lambda x: x[1])
	ans = [arr[0][0]]
	found = True
	for i in range(1, len(arr)):
		if arr[i - 1][0] in arr[i][0]:
			ans.append(arr[i][0])
		else:
			found = False
			break
	if found:
		print('YES')
		for i in ans:
			print(i)
	else:
		print('NO')
remained_test_case = 1
while remained_test_case > 0:
	question2()
	remained_test_case -= 1


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


n = int(input())
ss = []
ss_num = {}
for i in range(n):
	s = input()
	ss_num[i] = len(s)
	ss.append(s)
flag = True
sorted_s_num = sorted(ss_num.items(), key=lambda x: x[1], reverse=False)
i1 = ss[sorted_s_num[0][0]]
for (i_2, j) in sorted_s_num[1:]:
	i2 = ss[i_2]
	if i1 in i2:
		i1 = i2
		continue
	else:
		flag = False
		break
if flag:
	print('YES')
	for (i_2, j) in sorted_s_num:
		print(ss[i_2])
else:
	print('NO')


def main():
	n = int(input())
	s = [input() for _ in range(n)]
	for i in range(n):
		for j in range(n):
			if len(s[i]) <= len(s[j]) and s[i] not in s[j]:
				print('NO')
				return
	s = sorted(s, key=len)
	print('YES')
	for i in range(n):
		print(s[i])
main()


n = int(input())
li = []
for x in range(n):
	li.append(input())
li = sorted(li, key=len)
res = 1
for x in range(n - 1):
	if li[x] in li[x + 1]:
		continue
	else:
		res = 0
		break
if res == 0:
	print('NO')
elif res == 1:
	print('YES')
	for x in li:
		print(x)


n = int(input())
s = [input() for i in range(n)]
s.sort(key=lambda x: len(x))
for i in range(n - 1):
	if s[i] in s[i + 1]:
		continue
	else:
		print('NO')
		exit(0)
print('YES')
print(*s, sep='\n')


strs = []
for i in range(int(input())):
	strs.append(input())
strs = sorted(strs, key=len)
str2 = strs
flag = True
for i in range(len(strs)):
	for j in range(i, len(strs)):
		if strs[i] not in str2[j]:
			flag = False
			break
	if flag == False:
		break
if flag == False:
	print('NO')
else:
	print('YES')
	for i in strs:
		print(i)


n = int(input())
t = [str(input())]
for val in range(1, n):
	g = str(input())
	te = t
	for val in range(len(t)):
		if g in t[val]:
			te.insert(val, g)
			break
		if t[val] not in g:
			break
	if t[len(t) - 1] in g and g != t[len(t) - 1]:
		te += [g]
	t = te
if len(t) == n:
	print('YES')
	for val in t:
		print(val)
else:
	print('NO')


s = sorted((input() for i in range(int(input()))), key=len)
if all((x in y for (x, y) in zip(s, s[1:]))):
	print('YES', *s, sep='\n')
else:
	print('NO')


n = int(input())
arr = []
for i in range(n):
	arr.append(input())
bfind = False
arr.sort(key=str.__len__)
for (i, v1) in enumerate(arr):
	if not bfind:
		for v2 in arr[i + 1:]:
			if not v1 in v2:
				bfind = True
				break
if bfind:
	print('NO')
else:
	print('YES')
	for i in arr:
		print(i)


n = int(input())
d = {}
c = []
for i in range(1, 101):
	d[i] = []
for i in range(n):
	s = input()
	d[len(s)].append(s)
for key in d:
	if len(set(d[key])) > 1:
		print('NO')
		exit()
f = []
flag = 0
for key in d:
	f.append([key, d[key]])
f = sorted(f)
f1 = []
for i in range(len(f)):
	if len(f[i][1]) != 0:
		f1.append(f[i])
for i in range(len(f1) - 1):
	if f1[i][1][0] not in f1[i + 1][1][0]:
		flag += 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in range(len(f1)):
		for j in range(len(f1[i][1])):
			print(f1[i][1][j])


n = int(input())
(s, d) = ([], 0)
for i in range(n):
	t = input()
	s.append((len(t), t))
s.sort()
for i in range(len(s) - 1):
	if s[i][1] in s[i + 1][1]:
		d += 1
if d == len(s) - 1:
	print('YES')
	for i in range(len(s)):
		print(s[i][1])
else:
	print('NO')


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	n = int(input())
	s = []
	for i in range(n):
		t = str(input())
		s.append(t)
	if n == 1:
		print('YES')
		print(s[0])
	else:
		ss = sorted(s, key=lambda x: (len(x), x))
		f = True
		for j in range(1, n):
			if str(ss[j]).find(str(ss[j - 1])) == -1:
				f = False
				break
		if f:
			print('YES')
			for x in ss:
				print(x)
		else:
			print('NO')
main()


def contains(main, sub):
	for j in range(len(main) - (len(sub) - 1)):
		if main[j:j + len(sub)] == sub:
			return True
	return False
n = int(input())
s = []
for i in range(n):
	s.append(input())
s.sort(key=len)
flag = 0
for i in range(len(s) - 1):
	if contains(s[i + 1], s[i]) == False:
		print('NO')
		flag = 1
		break
if flag == 0:
	print('YES')
	for i in range(len(s)):
		print(s[i])


n = int(input())
a = []
for i in range(0, n):
	s = input()
	a.append(s)
for i in range(0, n):
	for j in range(0, n - 1):
		if a[j + 1] in a[j]:
			temp = a[j]
			a[j] = a[j + 1]
			a[j + 1] = temp
q = 0
for i in range(0, n - 1):
	if a[i] not in a[i + 1]:
		q += 1
if q == 0:
	print('YES')
	for i in a:
		print(i)
else:
	print('NO')


n = int(input())
l = []
for i in range(n):
	x = input()
	l.append(x)
l.sort(key=len)
c = True
for i in range(n - 1):
	if l[i] not in l[i + 1]:
		c = False
if c:
	print('YES')
	[print(x) for x in l]
else:
	print('NO')


n = int(input())
lis = []
ans = 'YES'
for i in range(n):
	lis.append(input())
lis = sorted(lis, key=lambda i: len(i))
for i in range(n - 1):
	if lis[i + 1].find(lis[i]) == -1:
		ans = 'NO'
		break
	else:
		continue
if ans == 'YES':
	print(ans)
	for i in range(n):
		print(lis[i])
else:
	print(ans)


n = int(input())
strs = list()
for _ in range(n):
	strs.append(input())
sstrs = sorted(strs, key=lambda s: len(s))
ol = list()
is_ok = True
for s in sstrs:
	if any((x not in s for x in ol)):
		is_ok = False
		print('NO')
		break
	else:
		ol.append(s)
if is_ok:
	print('YES')
	print('\n'.join(sstrs))


def keyFunction(x):
	return len(x)
n = int(input())
m = n
l = []
while n > 0:
	s = input()
	l.append(s)
	n -= 1
l.sort(key=keyFunction)
flag = True
for i in range(1, len(l)):
	if l[i - 1] not in l[i]:
		flag = False
		break
if flag:
	print('YES')
	for i in l:
		print(i)
else:
	print('NO')


arr2 = []
for _ in range(int(input())):
	n = input()
	arr2.append(n)
arr2 = sorted(arr2, key=len)
for k in range(len(arr2) - 1):
	if arr2[k] not in arr2[k + 1]:
		print('NO')
		exit()
print('YES')
for kk in arr2:
	print(kk)


z = int(input())
d = []
t = True
for i in range(z):
	x = input()
	d.append(x)
d.sort(key=len)
for i in range(1, len(d)):
	if d[i - 1] not in d[i]:
		t = False
if t:
	print('YES')
	for i in d:
		print(i)
else:
	print('NO')


x = int(input())
l = []
b = {}
lo = []
for __ in range(x):
	a = input()
	b[len(a)] = a
	lo.append(a)
	l.append(len(a))
l.sort()
f = 0
k = [b[l[0]]]
for i in range(1, len(l)):
	if b[l[i - 1]] not in b[l[i]]:
		f = 1
	else:
		k.append(b[l[i]])
if len(list(set(k))) != len(list(set(lo))):
	f = 1
if f == 0:
	print('YES')
	for i in k:
		print(i)
else:
	print('NO')


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())
strv = []
for i in range(n):
	strv.append(input())
strv.sort(key=len)
ans = True
for i in range(1, len(strv)):
	if strv[i - 1] not in strv[i]:
		ans = False
		break
if not ans:
	print('NO')
else:
	print('YES')
	print('\n'.join(strv))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [tuple(map(int, l.split())) for l in sys.stdin]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = sorted([S() for _ in range(n)], key=lambda x: len(x))
	for i in range(n - 1):
		if a[i] not in a[i + 1]:
			return 'NO'
	return 'YES\n{}'.format('\n'.join(a))
print(main())


def find(l):
	for i in l:
		f = 0
		for j in l:
			if i not in j:
				f += 1
				break
		if f == 0:
			return i
	return -1
n = int(input())
l = []
for i in range(n):
	s = input()
	l.append(s)
ans = []
f = 0
for i in range(n):
	s = find(l)
	if s == -1:
		f += 1
		break
	ans.append(s)
	l.remove(s)
if f:
	print('NO')
else:
	print('YES')
	for i in ans:
		print(i)


from sys import stdin
import re
stdin.readline()
ary = list(map(str, stdin.readlines()))
for i in range(len(ary)):
	ary[i] = ary[i].strip()
ary.sort(key=len)

def solve():
	global ary
	for i in range(1, len(ary)):
		if ary[i - 1] not in ary[i]:
			print('NO')
			return
	print('YES')
	print('\n'.join(ary))
solve()


n = int(input())
A = []
for _ in range(n):
	A.append(input())
A.sort(key=len)
last = A[0]
flag = True
for i in range(1, n):
	s = A[i]
	if last not in s:
		flag = False
		break
	last = s
if flag:
	print('YES')
	for i in range(n):
		print(A[i])
else:
	print('NO')


n = int(input().strip())
l = []
for _ in range(n):
	l.append(input().strip())
l.sort(key=lambda x: len(x))
long = l[-1]
possible = True
dic = {}
for i in l:
	for j in l:
		if len(j) <= len(i):
			possible = j in i
		if not possible:
			break
	if not possible:
		break
if not possible:
	print('NO')
else:
	print('YES')
	print('\n'.join(l))


ans = []

def check():
	for (i, x) in enumerate(ans):
		for j in range(i + 1, len(ans)):
			if ans[j].find(x) == -1:
				return False
	return True

def insert(ins):
	pos = len(ans)
	for (i, x) in enumerate(ans):
		if ins.find(ans[i]) == -1:
			pos = i
			break
	ans.insert(pos, ins)
	return check()

def main():
	n = int(input())
	a = []
	for _ in range(n):
		a.append(input())
	for x in a:
		if not insert(x):
			print('NO')
			return
	print('YES')
	for x in ans:
		print(x)
main()


import sys
n = int(input())
a = []
while n:
	a.append(input())
	n -= 1
a.sort(key=len)
for i in range(len(a) - 1):
	if a[i] not in a[i + 1]:
		print('NO')
		sys.exit(0)
print('YES')
for i in a:
	print(i)


n = int(input())
arr = []
for _ in range(n):
	string = input()
	arr.append(string)
arr.sort(key=len)
flag = True
for _ in range(len(arr) - 1):
	if arr[_] in arr[_ + 1]:
		continue
	else:
		flag = False
		break
if flag:
	print('YES')
	for _ in arr:
		print(_)
else:
	print('NO')


import functools
n = int(input())
words = [input() for i in range(n)]
byLen = [[] for i in range(101)]
for w in words:
	byLen[len(w)].append(w)
possible = True
result = []
for i in range(100, 0, -1):
	if len(byLen[i]) == 0:
		continue
	allEqual = True
	first = byLen[i][0]
	for w in byLen[i][1:]:
		if w != first:
			allEqual = False
			break
	if not allEqual:
		possible = False
		break
if not possible:
	print('NO')
	exit()
words.sort(key=lambda w: len(w))
for i in range(len(words) - 1):
	if not words[i] in words[i + 1]:
		possible = False
		break
if possible:
	print('YES')
	for w in words:
		print(w)
else:
	print('NO')


n = int(input())
array = []
for j in range(n):
	array.append(str(input()))
for j in range(n):
	index = j
	for k in range(j + 1, n):
		if array[k] in array[index]:
			index = k
	(array[j], array[index]) = (array[index], array[j])
impossible = False
for j in range(n - 1):
	if array[j] not in array[j + 1]:
		impossible = True
		break
if impossible:
	print('NO')
else:
	print('YES')
	for j in range(n):
		print(array[j])


import sys
n = int(sys.stdin.readline())

def subSort(n):
	allS = {}
	for t in range(n):
		s = sys.stdin.readline().strip()
		try:
			allS[len(s)].append(s)
		except:
			allS[len(s)] = [s]
	allL = list(allS)
	allL.sort()
	last = ''
	retS = 'YES\n'
	for length in allL:
		for s in allS[length]:
			if not last in s:
				return 'NO'
			else:
				retS = retS + s + '\n'
				last = s
	return retS
print(subSort(n))


n = int(input())
arr = []

def contains(sub, strin):
	m = len(sub)
	n = len(strin)
	for i in range(n - m + 1):
		if strin[i:i + m] == sub:
			return 1
	return 0
for i in range(n):
	arr.append(str(input()))
arr = sorted(arr, key=lambda x: len(x))
t = 1
for i in range(n):
	for j in range(i, n):
		if not contains(arr[i], arr[j]):
			print('NO')
			t = 0
			break
	if t == 0:
		break
if t == 1:
	print('YES')
	for j in arr:
		print(j)


n = int(input())
l = []
for i in range(n):
	l.append(input())
l = sorted(l, key=len)
k = 0
for i in range(len(l) - 1):
	if l[i] not in l[i + 1]:
		print('NO')
		k = -1
		break
if k != -1:
	print('YES')
	for i in range(len(l)):
		print(l[i])


n = int(input())
arr = []
for i in range(0, n):
	arr.append(input())
arr = sorted(arr, key=lambda x: len(x))
x = 1
for i in range(0, n - 1):
	if arr[i] not in arr[i + 1]:
		x = 0
		break
if x == 1:
	print('YES')
	for i in range(0, n):
		print(arr[i])
else:
	print('NO')


def solve(l):
	for i in range(1, n):
		if not l[i - 1] in l[i]:
			return False
	return True
n = int(input())
l = []
for n0 in range(n):
	l.append(input())
l.sort(key=len)
if solve(l):
	print('YES')
	for e in l:
		print(e)
else:
	print('NO')


n = int(input())
s = ['.' for i in range(101)]
d = dict()
counter = 0
for i in range(n):
	k = input()
	k = k
	if s[len(k)] != k and s[len(k)] != '.':
		print('NO')
		counter = 1
		break
	s[len(k)] = k
	if len(k) not in d:
		d[len(k)] = [k, 1]
	else:
		d[len(k)][1] += 1
key = list(d.keys())
key.sort()
if counter == 0:
	pred = d[min(key)][0]
	for i in key:
		if pred not in d[i][0]:
			counter = 1
			print('NO')
			break
		pred = d[i][0]
if counter == 0:
	print('YES')
	for i in key:
		for j in range(d[i][1]):
			print(d[i][0])


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


n = int(input())
l = []
t = {}
for i in range(n):
	s = input()
	if len(s) in t:
		t[len(s)].append(s)
	else:
		t[len(s)] = [s]
r = 0
for i in sorted(t):
	for j in t[i]:
		l.append(j)
for i in range(1, n):
	for j in range(0, i):
		if not l[j] in l[i]:
			r = 1
			break
if r == 1:
	print('NO')
else:
	print('YES')
	for i in l:
		print(i)


l = []
t = 0
n = int(input())
for x in range(n):
	p = input()
	l.append(p)
for i in range(n):
	for j in range(n - i - 1):
		if len(l[j]) > len(l[j + 1]):
			(l[j], l[j + 1]) = (l[j + 1], l[j])
l = l[::-1]
i = 0
j = 1
while j < len(l):
	one = l[i]
	two = l[j]
	if two in one:
		t = 0
	else:
		t = 1
	if t == 1:
		print('NO')
		break
	i = i + 1
	j = j + 1
if t == 0:
	print('YES')
	l = l[::-1]
	for u in l:
		print(u)


n = int(input())
a = []
for i in range(n):
	a.append(input())
z = []
for i in a:
	z.append([len(i), i])
x = sorted(z, key=lambda z: z[0])
for i in range(n - 1, -1, -1):
	for j in range(i):
		if x[j][1] not in x[i][1]:
			print('NO')
			exit()
print('YES')
for i in range(n):
	print(x[i][1])


def SubStrings(n, s):
	s.sort(key=len)
	i = n - 1
	while i > 0:
		if s[i - 1] not in s[i]:
			return 'NO'
		i = i - 1
	return s
x = int(input())
l = []
for i in range(x):
	l1 = input()
	l.append(l1)
res = SubStrings(x, l)
if res == 'NO':
	print('NO')
else:
	print('YES')
	for i in range(len(res)):
		print(res[i])


n = int(input())
s = [input() for _ in [0] * n]
for i in range(n):
	for j in range(n - 1, i, -1):
		if len(s[j]) < len(s[j - 1]):
			(s[j], s[j - 1]) = (s[j - 1], s[j])
for i in range(n - 1):
	if s[i] not in s[i + 1]:
		print('NO')
		exit()
print('YES')
for k in s:
	print(k)


n = int(input())
b = {}
a = []
t = 0
x = -1
for _ in range(n):
	a.append(input())
for i in range(n):
	l = len(a[i])
	if l in b:
		p = b[l]
		if p != a[i]:
			t = t + 1
			break
	else:
		b[l] = a[i]
	x = max(l, x)
	if t == 1:
		break
if t == 1:
	print('NO')
else:
	c = []
	for i in range(1, x + 1):
		if i in b:
			c.append(b[i])
	l = len(c)
	i = 0
	while i + 1 < l:
		if c[i + 1].find(c[i]) == -1:
			t += 1
			break
		i += 1
	if t == 1:
		print('NO')
	else:
		print('YES')
		for i in c:
			for j in a:
				if i == j:
					print(i)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
n = get_int()
arr = []
for i 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(*arr, sep='\n')


n = int(input())
res = []
for i in range(n):
	s = input()
	res.append(s)
res.sort(key=len)
f = True
for i in range(n - 1):
	if res[i] not in res[i + 1]:
		f = False
		break
if not f:
	print('NO')
else:
	print('YES')
	for k in res:
		print(k)


n = int(input())
ls = list()
for i in range(n):
	ls.append(input())
ls = sorted(ls, key=len)
f = 1
mm = n - 1
for i in range(n - 1):
	for j in range(i + 1, n):
		if ls[i] not in ls[j]:
			f = 0
			break
	if not f:
		break
if f:
	print('YES')
	for i in range(n):
		print(ls[i])
else:
	print('NO')


def substring(s1, s2):
	if len(s1) > len(s2):
		return s2 in s1
	else:
		return s1 in s2
d = {}
for _ in range(int(input())):
	s = input().strip()
	if len(s) in d.keys():
		d[len(s)].append(s)
	else:
		d[len(s)] = [s]
flag = 1
for i in sorted(d.keys()):
	if len(d[i]) > 1:
		for j in d[i]:
			if not substring(d[i][0], j):
				flag = 0
				break
arr = []
for i in sorted(d.keys()):
	arr.append(d[i][0])
for i in range(len(arr) - 1):
	if not substring(arr[i], arr[i + 1]):
		flag = 0
		break
if flag == 1:
	print('YES')
	for i in sorted(d.keys()):
		for j in d[i]:
			print(j)
else:
	print('NO')


times = int(input())
words = list()
while times > 0:
	word = input()
	words.append(word)
	times -= 1
swords = sorted(words, key=len)
j = 0
while j < len(swords) - 1:
	if swords[-1].count(swords[j]) >= 1 and swords[j + 1].count(swords[j]) >= 1:
		pass
	else:
		print('NO')
		exit()
	j += 1
print('YES')
for t in swords:
	print(t)


n = int(input())
v = [input() for i in range(n)]
g = [v[0]]
sol = True
for i in range(1, n):
	ins = False
	for j in range(len(g) - 1, -1, -1):
		if len(v[i]) > len(g[j]):
			if g[j] in v[i] and (j == len(g) - 1 or v[i] in g[j + 1]):
				g.insert(j + 1, v[i])
				ins = True
				break
			else:
				sol = False
				break
		if not sol:
			break
	if not ins:
		if v[i] in g[0]:
			g.insert(0, v[i])
		else:
			sol = False
			break
if not sol:
	print('NO')
else:
	print('YES')
	for i in range(len(g)):
		print(g[i])


numberOfStrings = int(input())
list = list((input() for _ in range(numberOfStrings)))
for i in range(numberOfStrings):
	for j in range(i + 1, numberOfStrings):
		if len(list[i]) > len(list[j]):
			temp = list[i]
			list[i] = list[j]
			list[j] = temp
count = 0
result = ''
for i in range(numberOfStrings - 1):
	if list[i] in list[i + 1]:
		result += list[i] + '\n'
		count += 1
if numberOfStrings - 1 == count:
	result += list[-1]
	print('YES')
	print(result)
else:
	print('NO')


n = int(input())
strings = []
for _ in range(n):
	strings.append(input())
strings.sort(key=lambda x: len(x))
for i in range(n - 1):
	if strings[i] not in strings[i + 1]:
		print('NO')
		exit()
print('YES')
print('\n'.join(strings))


n = int(input())
a = []
for _ in range(n):
	a.append(input())
a.sort(key=lambda x: len(x))
for i in range(n - 1):
	for j in range(len(a[i + 1]) - len(a[i]) + 1):
		if a[i + 1][j:j + len(a[i])] == a[i]:
			break
	else:
		print('NO')
		exit(0)
print('YES')
for i in a:
	print(i)


n = int(input())
a = [input().strip() for x in range(n)]
a.sort(key=lambda x: len(x))
fl = True
for i in range(1, n):
	if a[i - 1] == a[i]:
		continue
	if len(a[i - 1]) < len(a[i]):
		if a[i - 1] in a[i]:
			continue
	print('NO')
	break
else:
	print('YES')
	print('\n'.join(a))


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


n = int(input())
mas = []
for i in range(n):
	temp = input()
	mas.append([len(temp), temp])
mas.sort()
for i in range(n - 1):
	if mas[i + 1][1].find(mas[i][1]) == -1:
		print('NO')
		exit()
print('YES')
for i in range(n):
	print(mas[i][1])


s = [input() for i in range(int(input()))]
s.sort(key=len)
for (i, j) in zip(s, s[1:]):
	if i not in j:
		print('NO')
		exit()
print('YES')
for i in s:
	print(i)


n = int(input())
s = []
for i in range(n):
	s.append(input())
s.sort(key=len)
for i in range(n):
	for j in range(i):
		if s[j] not in s[i]:
			print('NO')
			exit()
print('YES')
print(*s, sep='\n')


x = []
for i in range(int(input())):
	x.append(input())
x.sort()
x.sort(key=lambda i: len(i))
k = 0
for i in range(len(x) - 1):
	if x[i] not in x[i + 1]:
		k = 1
if k == 0:
	print('YES')
	for i in range(len(x)):
		print(x[i])
else:
	print('NO')


c = []
for i in range(int(input())):
	c.append(input())
c = sorted(c, key=len)
d = []
flag = 0
for i in range(len(c)):
	for j in range(i + 1, len(c)):
		if c[i] not in c[j]:
			print('NO')
			flag = 1
			break
	if flag == 1:
		break
if flag == 0:
	print('YES')
	for i in c:
		print(i)


n = int(input())
words = []
for i in range(n):
	words.append(input())
words.sort(key=len)
r = True
for i in range(n - 2, -1, -1):
	if words[i] not in words[i + 1]:
		r = False
		break
if r:
	print('YES')
	for i in range(n):
		print(words[i])
else:
	print('NO')


n = int(input())
x = []
for i in range(n):
	temp = input()
	x.append([len(temp), temp])
x.sort()
currCount = 0
for i in range(1, n):
	if x[i - 1][1] in x[i][1]:
		currCount += 1
	else:
		break
if currCount == n - 1:
	print('YES')
	for i in x:
		print(i[1])
else:
	print('NO')


n = int(input())
x = []
y = 0
for i in range(n):
	s = input()
	x.append(s)
for i in range(n - 1):
	for j in range(i + 1, n):
		if len(x[j]) < len(x[i]):
			(x[i], x[j]) = (x[j], x[i])
for i in range(1, n):
	if x[i - 1] in x[i]:
		y += 1
	elif x[i - 1] == x[i]:
		y += 1
	else:
		print('NO')
		break
if y == n - 1:
	print('YES')
	for i in x:
		print(i)


def solveMeFirst(n, ar):
	final = []
	ar.sort(key=len)
	if n == 1:
		print('YES')
		print(ar[0])
		return 0
	for i in range(0, len(ar)):
		if i + 1 < len(ar):
			if ar[i] in ar[i + 1]:
				final = final + [ar[i]]
			else:
				print('NO')
				return 0
		elif final[i - 1] in ar[i]:
			final = final + [ar[i]]
		else:
			print('NO')
			return 0
	print('YES')
	for val in final:
		print(val)
n = int(input())
ar = []
for i in range(0, n):
	inputval = input()
	ar.append(inputval)
solveMeFirst(n, ar)


a = int(input(''))
t = []
q = []
l = []
z = []
s = []
f = 0
j = 0
d = 0
v = 0
for i in range(a):
	b = input('')
	t.append(b)
	z.append(len(b))
import copy
x = copy.deepcopy(z)
y = copy.deepcopy(t)
for il in range(len(t)):
	w = z.index(max(z))
	z.remove(z[w])
	j = 0
	for kl in range(len(t)):
		if not t[j] in t[w]:
			break
		else:
			f = f + 1
		j = j + 1
	t.remove(t[w])
if f == int(a * (a + 1) / 2):
	print('YES')
	for it in range(len(x)):
		e = x.index(min(x))
		l.append(y[e])
		x.remove(x[e])
		y.remove(y[e])
	for kll in range(len(l)):
		print(l[v])
		v = v + 1
else:
	print('NO')


n = int(input())
string = []
for _ in range(n):
	string.append(input())
string.sort(key=len)
flag = True
for i in range(n - 1):
	s = string[i]
	s_n = string[i + 1]
	if s_n.find(s) == -1:
		flag = False
		break
if flag == False:
	print('NO')
if flag == True:
	print('YES')
	for s in string:
		print(s)


args = []
for _ in range(int(input())):
	s = input()
	args.append((len(s), s))
args.sort()
sortedArgs = []
for s in args:
	sortedArgs.append(s[1])
s_1 = sortedArgs[0]
for s in sortedArgs:
	if s_1 in s:
		s_1 = s
	else:
		print('NO')
		exit()
print('YES')
for s in sortedArgs:
	print(s)


def main():
	(d, r, a) = ({}, ['YES'], '')
	for _ in range(int(input())):
		s = input()
		d[s] = d.get(s, 0) + 1
	for b in sorted(d.keys(), key=len):
		if a in b:
			r += [b] * d[b]
			a = b
		else:
			print('NO')
			return
	print('\n'.join(r))
main()


import sys
n = int(input())
L = []
for _ in range(n):
	L.append(input())
for i in range(n - 1):
	for j in range(i + 1, n):
		if len(L[i]) > len(L[j]):
			temp = L[i]
			L[i] = L[j]
			L[j] = temp
for i in range(n - 1):
	if L[i + 1].find(L[i]) == -1:
		print('NO')
		sys.exit(0)
print('YES')
for x in L:
	print(x)


a = int(input())
b = list()
for i in range(a):
	c = input()
	b.append(c)
max_len = 0
max_id = 0
d = b[0]
for j in range(len(b)):
	for i in range(len(b[:len(b) - j])):
		if len(b[i]) > max_len:
			max_len = len(b[i])
			max_id = i
			d = b[i]
	b = b[:max_id] + b[max_id + 1:]
	b.append(d)
	max_len = 0
	max_id = 0
	d = b[0]
flag = True
for i in range(len(b) - 1):
	if b[i + 1] not in b[i]:
		flag = False
		break
if flag:
	print('YES')
	for i in range(len(b) - 1, -1, -1):
		print(b[i])
else:
	print('NO')


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect

def solve():
	n = scanner()
	ans = []
	for i in range(n):
		s = string()
		ans.append([len(s), s])
	ans.sort()
	result = []
	for i in range(len(ans) - 1):
		s = ans[i][1]
		result.append(s)
		if s not in ans[i + 1][1]:
			print('NO')
			return
	result.append(ans[-1][1])
	print('YES')
	for x in result:
		print(x)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(1):
	solve()


n = int(input())
l = []
k = 0
for i in range(0, n):
	m = input()
	l.append(m)
l.sort(key=len)
for i in range(0, n - 1):
	if l[i + 1].find(l[i]) != -1:
		k += 1
if k >= n - 1:
	print('YES')
	for x in range(len(l)):
		print(l[x])
else:
	print('NO')


n = int(input())
ss = []
for _ in range(n):
	ss.append(input().strip())
ss = sorted(ss, key=lambda x: len(x))
x = ss[0]
ans = True
for i in ss[1:]:
	if not x in i:
		ans = False
		break
	x = i
if ans:
	print('YES')
	for i in ss:
		print(i)
else:
	print('NO')


n = int(input())
inpL = []
ordList = []
isTrue = True
for z in range(n):
	inpL.append(str(input()))
inpL.sort(reverse=True, key=len)
ordList.append(inpL[0])
inpL.remove(inpL[0])
while len(inpL) > 0:
	this = inpL[0]
	inpL.remove(this)
	ordList.append(this)
	for i in ordList:
		if this not in i:
			isTrue = False
			break
	if isTrue == False:
		break
if isTrue:
	print('YES')
	ordList.reverse()
	for j in ordList:
		print(j)
else:
	print('NO')


def parting(a, low, high):
	p = high
	fh = low
	for i in range(low, high):
		if a[i] < a[p]:
			temp = a[i]
			a[i] = a[fh]
			a[fh] = temp
			tempo = s[i]
			s[i] = s[fh]
			s[fh] = tempo
			fh = fh + 1
	temp = a[p]
	a[p] = a[fh]
	a[fh] = temp
	tempo = s[p]
	s[p] = s[fh]
	s[fh] = tempo
	return fh

def sorting(a, low, high):
	if high - low > 0:
		p = parting(a, low, high)
		sorting(a, low, p - 1)
		sorting(a, p + 1, high)
N = int(input())
s = [input() for i in range(0, N)]
l = [len(s[i]) for i in range(0, N)]
sorting(l, 0, N - 1)
b = 0
for i in range(0, N - 1):
	if s[i + 1].find(s[i]) == -1:
		b = 1
		break
if b == 1:
	print('NO')
else:
	print('YES')
	for i in range(0, N):
		print(s[i])


(h, c) = ([], 0)
for i in range(int(input())):
	k = input()
	h.append((len(k), k))
h = sorted(h)
for i in range(len(h) - 1):
	if h[i][1] not in h[i + 1][1]:
		c = 1
		break
if c == 1:
	print('NO')
else:
	print('YES')
	for (_, i) in h:
		print(i)


n = int(input())
arr = []
for i in range(n):
	s = input()
	arr.append((-1 * len(s), s))
arr.sort()
arr1 = []
arr1.append(arr[0][1])
flag = 0
for i in range(1, n):
	if arr[i][1] in arr[i - 1][1]:
		arr1.append(arr[i][1])
	else:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in range(n):
		print(arr1[n - i - 1])


from sys import stdin, stdout
n = int(stdin.readline().rstrip())
a = list()
for _ in range(n):
	a.append(stdin.readline().rstrip())
a.sort(key=len)
i = 1
l = len(a)
while i < l:
	if a[i].find(a[i - 1]) == -1:
		break
	i += 1
if i == l:
	stdout.write('YES\n')
	for w in a:
		stdout.write(w + '\n')
else:
	stdout.write('NO')


n = int(input())
d = {}
for i in range(n):
	s = input()
	l = len(s)
	if l in d:
		d[l].append(s)
	else:
		d[l] = [s]
te = 0
for i in d:
	if len(d[i]) != 1:
		pp = set(d[i])
		if len(pp) != 1:
			te = 1
			break
if te == 1:
	print('NO')
else:
	li = sorted(list(d.keys()))
	le = len(li)
	pe = 0
	for i in range(le - 1):
		k1 = d[li[i]][0]
		k2 = d[li[i + 1]][0]
		if k1 not in k2:
			pe = 1
			break
	if pe == 1:
		print('NO')
	else:
		print('YES')
		for i in li:
			for ci in d[i]:
				print(ci)


n = int(input())
strings = []
for _ in range(n):
	strings.append(input().strip())
strings = sorted(strings, key=len)
flag = False
for i in range(len(strings) - 1):
	for j in range(i + 1, len(strings)):
		if strings[i] not in strings[j]:
			flag = True
if flag:
	print('NO')
else:
	print('YES')
	for i in strings:
		print(i)


n = int(input())
a = []
for i in range(n):
	a.append(input())
a.sort(key=len)
answer = 'YES'
for i in range(n - 1):
	if a[i] in a[i + 1]:
		answer += '\n' + a[i]
	else:
		answer = 'NO'
		a[-1] = ''
		break
if answer[0:3] == 'YES':
	print(answer + '\n' + a[-1])
else:
	print(answer)


n = int(input())
a = []
k = 0
for x in range(n):
	a.append(input())
for x in range(n - 1):
	for y in range(x + 1, n):
		if len(a[x]) > len(a[y]):
			(a[x], a[y]) = (a[y], a[x])
for i in range(n - 1):
	if a[i] not in a[i + 1]:
		k = 1
		break
if k == 0:
	print('YES')
	for x in a:
		print(x)
else:
	print('NO')


def get_min_index(a_list, start, end):
	min_index = start
	for i in range(start, end):
		if a_list[i] in a_list[min_index]:
			min_index = i
	return min_index

def selection_sort(a_list):
	for i in range(len(a_list)):
		min_index = get_min_index(a_list, i, len(a_list))
		(a_list[i], a_list[min_index]) = (a_list[min_index], a_list[i])
n = int(input())
s = []
for _ in range(n):
	s.append(input())
selection_sort(s)
is_sorted = True
for si in range(n - 1):
	if s[si] not in s[si + 1]:
		is_sorted = False
if is_sorted:
	print('YES')
	for j in range(n):
		print(s[j])
else:
	print('NO')


arr = []
for _ in range(int(input().strip())):
	arr.append(input().strip())
arr.sort(key=len)
ans = 'YES'
for i in range(1, len(arr)):
	if arr[i - 1] not in arr[i]:
		ans = 'NO'
		break
if ans == 'YES':
	print(ans)
	print('\n'.join(arr))
else:
	print(ans)


n = int(input())
line = []
for i in range(n):
	word = input()
	line.append((len(word), word))
line.sort()
trig = True
for i in range(n - 1):
	if line[i][1] not in line[i + 1][1]:
		trig = False
		break
if trig:
	print('YES')
	for i in range(n):
		print(line[i][1])
else:
	print('NO')


N = int(input())
A = []
for i in range(0, N):
	A.append(str(input()))
A = sorted(A, key=len)
counter = 0
for i in range(0, N - 1):
	if A[i] not in A[i + 1]:
		counter = 1
if counter == 1:
	print('NO')
else:
	print('YES')
	for i in range(0, N):
		print(A[i])


import sys
n = int(input())
arr = [input() for i in range(n)]
arr.sort(key=len)
for i in range(len(arr) - 2, -1, -1):
	if arr[i + 1].find(arr[i]) == -1:
		print('NO')
		sys.exit()
print('YES')
for i in arr:
	print(i)


l = []
for t in range(int(input())):
	s = input()
	l.append(s)
l.sort(key=len)
flag = 0
for i in range(len(l) - 1):
	if l[i] in l[i + 1]:
		flag = 0
	else:
		flag = 1
		break
if flag == 1:
	print('NO')
else:
	print('YES')
	for i in l:
		print(i)


n = int(input())
l = []
for _ in range(n):
	l.append(input())
l.sort(key=len)
p = 1
for i in range(n - 1):
	if l[i] not in l[i + 1]:
		p = 0
		break
if p == 0:
	print('NO')
else:
	print('YES')
	for i in l:
		print(i)


import operator
n = int(input())
l = {}
x = []
for i in range(n):
	e = input()
	l[e] = len(e)
	x.append(e)
t = True
sorted_l = sorted(l.items(), key=operator.itemgetter(1))
if len(sorted_l) == 1:
	print('YES')
	for i in range(x.count(sorted_l[0][0])):
		print(sorted_l[0][0])
else:
	for i in range(len(sorted_l) - 1):
		if sorted_l[i + 1][0].__contains__(sorted_l[i][0]) == False:
			t = False
			break
	if t == False:
		print('NO')
	else:
		print('YES')
		for i in sorted_l:
			for j in range(x.count(i[0])):
				print(i[0])


n = int(input())
arr = sorted([input() for _ in range(n)], key=lambda x: len(x))
for i in range(1, len(arr)):
	if arr[i - 1] not in arr[i]:
		print('NO')
		exit()
print('YES')
for x in arr:
	print(x)


from collections import Counter, defaultdict
BS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def to_base(s, b):
	res = ''
	while s:
		res += BS[s % b]
		s //= b
	return res[::-1] or '0'
alpha = 'abcdefghijklmnopqrstuvwxyz'
from math import floor, ceil, pi
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919]

def primef(n, plst=[]):
	if n == 1:
		return plst
	else:
		for m in primes:
			if n % m == 0:
				return primef(n // m, plst + [m])
		return primef(1, plst + [n])

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

def ii():
	return int(input())

def countOverlapping(string, sub):
	count = start = 0
	while True:
		start = string.find(sub, start) + 1
		if start > 0:
			count += 1
		else:
			return count
from copy import deepcopy
n = ii()
strings = [input() for _ in range(n)]
strings.sort(key=lambda x: len(x))
ans = []
cur = 1
for i in range(len(strings)):
	found = True
	for j in range(cur, len(strings)):
		if j != i:
			if strings[i] not in strings[j]:
				found = False
				break
	if not found:
		break
	else:
		ans.append(strings[i])
		cur += 1
if not found:
	print('NO')
else:
	print('YES')
	print('\n'.join(ans))


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

def sortL(a):
	fl = True
	while fl:
		fl = False
		for i in range(len(a) - 1):
			if len(a[i]) > len(a[i + 1]):
				(a[i], a[i + 1]) = (a[i + 1], a[i])
				fl = True

def check():
	for i in range(len(a) - 1):
		if a[i + 1].find(a[i]) == -1:
			return False
	return True
sortL(a)
if not check():
	print('NO')
	exit(0)
print('YES')
for i in range(len(a)):
	print(a[i])


n = int(input())
A = []
for _ in range(n):
	A.append(str(input()))
A.sort(key=len)
bool = True
for i in range(n - 1):
	if A[i] not in A[i + 1]:
		bool = False
		break
if bool:
	print('YES')
	for x in A:
		print(x)
else:
	print('NO')


n = int(input())
s = []
for i in range(n):
	s1 = input()
	s.append(s1)
l = []
for i in range(n):
	l.append(len(s[i]))
(l, s) = zip(*sorted(zip(l, s)))
flag = 1
for i in range(n - 1):
	if s[i] not in s[i + 1]:
		print('NO')
		flag = 0
		break
if flag == 1:
	print('YES')
	for i in range(n):
		print(s[i])


n = int(input())
strings = [input() for x in range(n)]
distinct = list(set(strings))
lengths = {}
for x in distinct:
	if len(x) in lengths:
		print('NO')
		break
	lengths[len(x)] = x
else:
	order = []
	for x in sorted(lengths.keys()):
		order.append(lengths[x])
	for x in range(len(order) - 1):
		if order[x] not in order[x + 1]:
			print('NO')
			break
	else:
		print('YES')
		for x in order:
			for y in range(strings.count(x)):
				print(x)


def substringsort(strings):
	strings.sort(key=len)
	sol = True
	for i in range(len(strings) - 1):
		if strings[i] in strings[i + 1]:
			pass
		else:
			sol = False
			break
	return sol
n = int(input())
strings = []
for counter in range(n):
	strings.append(input())
ans = substringsort(strings)
if ans:
	print('YES')
	for c in strings:
		print(c)
else:
	print('NO')


num_str = int(input())
str_list = [input() for _ in range(num_str)]
str_list = sorted(str_list, key=lambda x: len(x))
len_list = len(str_list)

def check_substr():
	for i in range(len_list - 1):
		if str_list[i] not in str_list[i + 1]:
			return 'NO'
	return 'YES'
ans = check_substr()
if ans == 'NO':
	print('NO')
else:
	print('YES')
	for elem in str_list:
		print(elem)


n = int(input())
d = {}
for i in range(n):
	x = input()
	if x in d:
		d[x][1] += 1
	else:
		d[x] = [len(x), 1]
l = sorted(d.items(), key=lambda x: x[1][0])
le = len(l)
for j in range(le - 1):
	if l[j][0] not in l[j + 1][0]:
		print('NO')
		exit()
print('YES')
for i in range(le):
	k = 0
	while k < l[i][1][1]:
		print(l[i][0])
		k += 1


n = int(input())
l = []
for i in range(n):
	l.append(input())
i = 0
while i < n - 1:
	i = 0
	while i < n - 1:
		if len(l[i]) > len(l[i + 1]):
			(l[i], l[i + 1]) = (l[i + 1], l[i])
			break
		i += 1
for i in range(n - 1):
	if l[i + 1].count(l[i]) == 0:
		print('NO')
		exit()
print('YES')
for s in l:
	print(s)


import sys, functools

def cc(fst, snd):
	lf = len(fst)
	ls = len(snd)
	return lf - ls

def contains(f, s):
	return f.find(s) != -1
n = int(input())
strs = sorted([s.strip() for s in sys.stdin], key=functools.cmp_to_key(cc))
flag = True
for i in range(1, n):
	for j in range(n - i):
		if len(strs[i + j]) == len(strs[j]):
			if not contains(strs[i + j], strs[j]) and (not contains(strs[j], strs[i + j])):
				flag = False
				break
		elif not contains(strs[i + j], strs[j]):
			flag = False
			break
if flag:
	print('YES')
	for s in strs:
		print(s)
else:
	print('NO')


n = int(input())
pal = []
for i in range(n):
	string = input()
	pal.append(string)
pal.sort(key=len)
minIndex = 0
flag = 0
for i in range(len(pal)):
	for j in range(i + 1, len(pal)):
		if pal[minIndex] not in pal[i + 1]:
			flag = 1
			break
	minIndex += 1
if flag == 0:
	print('YES')
	for i in pal:
		print(i)
else:
	print('NO')


n = int(input())
strings = []
for _ in range(n):
	strings.append(input())
sorted_strings = sorted(strings, key=len)
is_possible = True
for i in range(n - 1):
	if not sorted_strings[i] in sorted_strings[i + 1]:
		print('NO')
		is_possible = False
		break
if is_possible:
	print('YES')
	for string in sorted_strings:
		print(string)


a = [input() for i in range(int(input()))]
b = [max(a, key=lambda x: len(x))]
while len(a) > 1:
	m = max(a, key=lambda x: len(x))
	a.remove(m)
	m1 = max(a, key=lambda x: len(x))
	if m1 in m:
		b.append(m1)
	else:
		exit(print('NO'))
print('YES', *reversed(b[1:]), b[0], sep='\n')


num = int(input(''))
list1 = []
for i in range(0, num):
	list1.append(input(''))
list2 = sorted(list1, key=lambda i: len(i))
for i in range(1, num):
	if list2[i - 1] not in list2[i]:
		i = -1
		break
if i == num - 1:
	print('YES')
	for i in range(0, num):
		print(list2[i])
else:
	print('NO')


n = int(input())
l = []
ans = []
for i in range(n):
	l.append(input())
l.sort(key=len)
pol = False
for i in range(n - 1):
	if l[i] not in l[i + 1]:
		pol = True
		break
if pol:
	print('NO')
else:
	print('YES')
	for i in l:
		print(i)


n = int(input())
a = [input() for _ in range(n)]
a.sort(key=len)
for i in range(1, n):
	if a[i - 1] not in a[i]:
		print('NO')
		break
else:
	print('YES')
	print('\n'.join(a))


a = []
n = int(input())
for _ in range(n):
	a.append(input())
a.sort(key=len)
ans = 0
b = []
for i in range(n - 1):
	if a[i] in a[i + 1]:
		ans += 1
		b.append(a[i])
b.append(a[-1])
if ans == n - 1:
	print('YES')
	for i in b:
		print(i)
else:
	print('NO')


n = int(input())
a = [input() for _ in range(n)]
a = sorted(a, key=len)
sol = True
for i in range(1, n):
	for j in range(i - 1, -1, -1):
		if a[j] not in a[i]:
			sol = False
			break
	if not sol:
		break
if sol:
	print('YES')
	print('\n'.join(a))
else:
	print('NO')


all_str = []
for i in range(int(input())):
	all_str.append(input())
all_str.sort(key=lambda s: len(s))
ans = 'YES'
for i in range(1, len(all_str)):
	if not all_str[i - 1] in all_str[i]:
		ans = 'NO'
		break
print(ans)
if ans == 'YES':
	print('\n'.join(all_str))


n = int(input())
strs = []
for i in range(n):
	strs.append(input())
strs = sorted(strs, key=lambda x: len(x))
ok = True
for i in range(n - 1):
	if strs[i] not in strs[i + 1]:
		print('NO')
		ok = False
		break
if ok:
	print('YES')
	for i in range(n):
		print(strs[i])


n = int(input())
s = [input() for i in range(n)]
s.sort(key=len)
tmp = ''
for i in s:
	if tmp not in i:
		print('NO')
		exit()
	else:
		tmp = i
print('YES')
for i in s:
	print(i)


c = []
l = []
for _ in range(int(input())):
	s = input()
	c.append(s)
	l.append(len(s))
n = len(l)
for i in range(n - 1):
	for j in range(n - i - 1):
		if l[j] > l[j + 1]:
			(l[j], l[j + 1]) = (l[j + 1], l[j])
			(c[j], c[j + 1]) = (c[j + 1], c[j])
for i in range(1, n):
	if c[i - 1] not in c[i]:
		print('NO')
		break
else:
	print('YES')
	for k in c:
		print(k)


n = int(input())
a = []
for i in range(n):
	a.append(input())
a.sort(key=len)
i = 0
b = []
while True and i < n - 1:
	if a[i + 1].count(a[i]) < 1:
		print('NO')
		exit()
	i += 1
print('YES')
for i in a:
	print(i)


n = int(input())
a = []
for _ in range(n):
	x = input()
	a.append(x)
a = sorted(a, key=len)
f = True
for i in range(1, len(a)):
	if not a[i - 1] in a[i]:
		print('NO')
		f = False
		break
if f:
	print('YES')
	for s in a:
		print(s)


n = int(input())
words = []
flag = True
for i in range(n):
	words.append(str(input()))
words.sort(key=len)
for i in range(len(words) - 1):
	if words[i + 1].find(words[i]) != -1:
		continue
	else:
		flag = False
if flag:
	print('YES', *words, sep='\n')
else:
	print('NO')