s = eval(input())

s = s+s

p = eval(input())

if p in s:

    print("Yes")

else:

    print("No")

s = eval(input())

p = eval(input())

s = s*2

if p in s:

    print("Yes")

else:

    print("No")



s = eval(input())
s = s + s
p = eval(input())
if p in s:
    print("Yes")
else:
    print("No")

s = eval(input())
p = eval(input())
s = s * 2
if p in s:
    print("Yes")
else:
    print("No")

-s = s + s +s = s * 2