n = int(eval(input()))

s = eval(input())

dup = [s]

ans = 'Yes'

for i in range(n-1):

    next = eval(input())

    if s[-1]!=next[0] or next in dup:

        ans = 'No'

    else:dup.append(next)

    s = next

print(ans)
n = int(eval(input()))

before = ''

said = set([])

f = True

for i in range(n):

    if i==0:

        before = eval(input())

        said.add(before)

        continue

    s = eval(input())

    if before[-1] != s[0] or s in said:

        f = False

    before = s

    said.add(s)

print(('Yes' if f else 'No'))



n = int(eval(input()))
s = eval(input())
dup = [s]
ans = "Yes"
for i in range(n - 1):
    next = eval(input())
    if s[-1] != next[0] or next in dup:
        ans = "No"
    else:
        dup.append(next)
    s = next
print(ans)

n = int(eval(input()))
before = ""
said = set([])
f = True
for i in range(n):
    if i == 0:
        before = eval(input())
        said.add(before)
        continue
    s = eval(input())
    if before[-1] != s[0] or s in said:
        f = False
    before = s
    said.add(s)
print(("Yes" if f else "No"))

-s = eval(input()) -dup = [s] -ans = "Yes" -for i in range(n - 1): -    next = eval(input()) -    if s[-1] != next[0] or next in dup: -        ans = "No" -    else: -        dup.append(next) -    s = next -print(ans) +before = "" +said = set([]) +f = True +for i in range(n): +    if i == 0: +        before = eval(input()) +        said.add(before) +        continue +    s = eval(input()) +    if before[-1] != s[0] or s in said: +        f = False +    before = s +    said.add(s) +print(("Yes" if f else "No"))