from collections import deque



s = deque(eval(input()))

t = deque(eval(input()))

n=len(s)



yes = False

for _ in range(n):

    if s == t:

        yes = True

        break

    s.rotate()



print(('Yes' if yes else 'No'))
S = eval(input())

T = eval(input())

S = S * 2

yes = S.find(T) != -1

print(('Yes' if yes else 'No'))
from collections import deque

s = deque(eval(input()))
t = deque(eval(input()))
n = len(s)
yes = False
for _ in range(n):
    if s == t:
        yes = True
        break
    s.rotate()
print(("Yes" if yes else "No"))

S = eval(input())
T = eval(input())
S = S * 2
yes = S.find(T) != -1
print(("Yes" if yes else "No"))

-from collections import deque - -s = deque(eval(input())) -t = deque(eval(input())) -n = len(s) -yes = False -for _ in range(n): -    if s == t: -        yes = True -        break -    s.rotate() +S = eval(input()) +T = eval(input()) +S = S * 2 +yes = S.find(T) != -1