s=list(eval(input()))

t=eval(input())

ans=[]

for i in range(len(s)):

    s.insert(0,s.pop(-1))

    ans.append("".join(s))



print(("Yes" if t in ans else "No"))
s=list(eval(input()))

t=eval(input())

for i in range(len(s)):

    s.insert(0,s.pop(-1))

    word="".join(s)

    if word==t:

        print("Yes")

        exit()

print("No")
s = list(eval(input()))
t = eval(input())
ans = []
for i in range(len(s)):
    s.insert(0, s.pop(-1))
    ans.append("".join(s))
print(("Yes" if t in ans else "No"))

s = list(eval(input()))
t = eval(input())
for i in range(len(s)):
    s.insert(0, s.pop(-1))
    word = "".join(s)
    if word == t:
        print("Yes")
        exit()
print("No")

-ans = [] -    ans.append("".join(s)) -print(("Yes" if t in ans else "No")) +    word = "".join(s) +    if word == t: +        print("Yes") +        exit() +print("No")