print(("No" if (lambda w:(sum([w.count(s)-1 for s in w])) or sum([1-(w[i][0] == w[i-1][-1]) for i in range(1,len(w))]))([eval(input()) for i in range(int(eval(input())))]) else "Yes"))
print(("No" if (lambda w:(sum([w.count(s)-1 for s in w])) or sum([w[i][0] != w[i-1][-1] for i in range(1,len(w))]))([eval(input()) for i in range(int(eval(input())))]) else "Yes"))
print(
    (
        "No"
        if (
            lambda w: (sum([w.count(s) - 1 for s in w]))
            or sum([1 - (w[i][0] == w[i - 1][-1]) for i in range(1, len(w))])
        )([eval(input()) for i in range(int(eval(input())))])
        else "Yes"
    )
)

print(
    (
        "No"
        if (
            lambda w: (sum([w.count(s) - 1 for s in w]))
            or sum([w[i][0] != w[i - 1][-1] for i in range(1, len(w))])
        )([eval(input()) for i in range(int(eval(input())))])
        else "Yes"
    )
)

-            or sum([1 - (w[i][0] == w[i - 1][-1]) for i in range(1, len(w))]) +            or sum([w[i][0] != w[i - 1][-1] for i in range(1, len(w))])