N = int(eval(input()))

W = [eval(input()) for i in range(N)]



for a,b in zip(W,W[1:]):

    if a[-1] != b[0]:

        print('No')

        exit()



sl = len(set(W))

print(('Yes' if N == sl else 'No'))
N = int(eval(input()))

S = [eval(input()) for i in range(N)]

s = set()

p = None

for w in S:

    if w in s:

        print('No')

        exit()

    s.add(w)

    if p and p != w[0]:

        print('No')

        exit()

    p = w[-1]

print('Yes')

N = int(eval(input()))
W = [eval(input()) for i in range(N)]
for a, b in zip(W, W[1:]):
    if a[-1] != b[0]:
        print("No")
        exit()
sl = len(set(W))
print(("Yes" if N == sl else "No"))

N = int(eval(input()))
S = [eval(input()) for i in range(N)]
s = set()
p = None
for w in S:
    if w in s:
        print("No")
        exit()
    s.add(w)
    if p and p != w[0]:
        print("No")
        exit()
    p = w[-1]
print("Yes")

-W = [eval(input()) for i in range(N)] -for a, b in zip(W, W[1:]): -    if a[-1] != b[0]: +S = [eval(input()) for i in range(N)] +s = set() +p = None +for w in S: +    if w in s: -sl = len(set(W)) -print(("Yes" if N == sl else "No")) +    s.add(w) +    if p and p != w[0]: +        print("No") +        exit() +    p = w[-1] +print("Yes")