s = str(eval(input()))

t = str(eval(input()))





for i in range(len(s)):

    for j in s:

        if(t == s[i:]+s[:i]):

            print('Yes')

            exit()



print('No')

s = str(eval(input()))

t = str(eval(input()))



for i in range(len(s)):

    if(t == s[i:]+s[:i]):

        print('Yes')

        exit()



print('No')

s = str(eval(input()))
t = str(eval(input()))
for i in range(len(s)):
    for j in s:
        if t == s[i:] + s[:i]:
            print("Yes")
            exit()
print("No")

s = str(eval(input()))
t = str(eval(input()))
for i in range(len(s)):
    if t == s[i:] + s[:i]:
        print("Yes")
        exit()
print("No")

-    for j in s: -        if t == s[i:] + s[:i]: -            print("Yes") -            exit() +    if t == s[i:] + s[:i]: +        print("Yes") +        exit()