Write a program which finds a pattern $p$ in a ring shaped text $s$.     
ring = input()
ring_double = ring *2
test = input()
if test in ring_double:
	print('True')
else:
	print('No')
ring = input()
ring_double = ring *2
test = input()
if test in ring_double:
	print('Yes')
else:
	print('No')