import collections

N=int(eval(input()))

siritori=collections.defaultdict(int)

prev=" "

for i in range(N):

  word = eval(input())

  if word in siritori:

    print("No")

    exit(0)

  elif prev[-1]!=word[0] and i != 0:

    print("No")

    exit(0)

  siritori[word]+=1

  prev=word

print("Yes")

N = int(eval(input()))

s = set()



flag = True

for i in range(N):

    S = eval(input())

    if S in s:

        flag = False

    if i > 0 and S[0] != prev:

        flag = False

    s.add(S)

    prev = S[-1]

if flag:

    print("Yes")

else:

    print("No")

import collections

N = int(eval(input()))
siritori = collections.defaultdict(int)
prev = " "
for i in range(N):
    word = eval(input())
    if word in siritori:
        print("No")
        exit(0)
    elif prev[-1] != word[0] and i != 0:
        print("No")
        exit(0)
    siritori[word] += 1
    prev = word
print("Yes")

N = int(eval(input()))
s = set()
flag = True
for i in range(N):
    S = eval(input())
    if S in s:
        flag = False
    if i > 0 and S[0] != prev:
        flag = False
    s.add(S)
    prev = S[-1]
if flag:
    print("Yes")
else:
    print("No")

-import collections - -siritori = collections.defaultdict(int) -prev = " " +s = set() +flag = True -    word = eval(input()) -    if word in siritori: -        print("No") -        exit(0) -    elif prev[-1] != word[0] and i != 0: -        print("No") -        exit(0) -    siritori[word] += 1 -    prev = word -print("Yes") +    S = eval(input()) +    if S in s: +        flag = False +    if i > 0 and S[0] != prev: +        flag = False +    s.add(S) +    prev = S[-1] +if flag: +    print("Yes") +else: +    print("No")