s = eval(input())

p = eval(input())

s += s

if p in s:

    print('Yes')

else:

    print('No')
s = eval(input())

p = eval(input())



s *= 2



if s.find(p) != -1:

    print("Yes")

else:

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

s = eval(input())
p = eval(input())
s *= 2
if s.find(p) != -1:
    print("Yes")
else:
    print("No")

-s += s -if p in s: +s *= 2 +if s.find(p) != -1: