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
bn
nm

NO NO YES YES YES YES NO YES YES YES YES NO NO YES YES YES NO YES YES NO YES YES YES YES YES YES NO NO YES NO YES YES NO NO YES YES YES YES YES YES YES YES YES YES YES NO YES YES YES YES YES NO NO NO NO NO YES NO YES YES YES NO NO YES YES YES NO NO NO YES YES YES YES YES YES YES YES NO YES YES YES YES YES YES YES NO
p = input().strip()
n = int(input())
r = 0
s = [0] * n
for i in range(n):
    s[i] = input().strip()
for i in range(n):
    for j in range(n):
        if p in s[i] + s[j]:
            r = 1
if r:
    print("YES")
else:
    print("NO")