s,p=[eval(input()) for i in range(2)]

s=s*3

if p in s:

    print('Yes')

else:

    print('No')
s,p=[eval(input()) for i in range(2)]

s=s*2

if p in s:

    print('Yes')

else:

    print('No')
s, p = [eval(input()) for i in range(2)]
s = s * 3
if p in s:
    print("Yes")
else:
    print("No")

s, p = [eval(input()) for i in range(2)]
s = s * 2
if p in s:
    print("Yes")
else:
    print("No")

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