s = eval(input())

t = eval(input())



ss = s+s+s



f = 0

for i in range(len(s)):

#    print(s[i:len(s)+i])

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

        f = 1





if f:

    print("Yes")

else:

    print("No")

s = eval(input())

t = eval(input())



ss = s+s



f = 0

for i in range(len(s)):

#    print(s[i:len(s)+i])

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

        f = 1





if f:

    print("Yes")

else:

    print("No")

s = eval(input())
t = eval(input())
ss = s + s + s
f = 0
for i in range(len(s)):
    #    print(s[i:len(s)+i])
    if ss[i : len(s) + i] == t:
        f = 1
if f:
    print("Yes")
else:
    print("No")

s = eval(input())
t = eval(input())
ss = s + s
f = 0
for i in range(len(s)):
    #    print(s[i:len(s)+i])
    if ss[i : len(s) + i] == t:
        f = 1
if f:
    print("Yes")
else:
    print("No")

-ss = s + s + s +ss = s + s