Running with barriers on the circle track is very popular in the country where Dasha lives, so no wonder that on her way to classes she saw the following situation:

The track is the circle with length L, in distinct points of which there are n barriers. Athlete always run the track in counterclockwise direction if you look on him from above. All barriers are located at integer distance from each other along the track. 

Her friends the parrot Kefa and the leopard Sasha participated in competitions and each of them ran one lap. Each of the friends started from some integral point on the track. Both friends wrote the distance from their start along the track to each of the n barriers. Thus, each of them wrote n integers in the ascending order, each of them was between 0 and L - 1, inclusively. [Image] Consider an example. Let L = 8, blue points are barriers, and green points are Kefa's start (A) and Sasha's start (B). Then Kefa writes down the sequence [2, 4, 6], and Sasha writes down [1, 5, 7]. 

There are several tracks in the country, all of them have same length and same number of barriers, but the positions of the barriers can differ among different tracks. Now Dasha is interested if it is possible that Kefa and Sasha ran the same track or they participated on different tracks. 

Write the program which will check that Kefa's and Sasha's tracks coincide (it means that one can be obtained from the other by changing the start position). Note that they always run the track in one direction — counterclockwise, if you look on a track from above. 


-----Input-----

The first line contains two integers n and L (1 ≤ n ≤ 50, n ≤ L ≤ 100) — the number of barriers on a track and its length. 

The second line contains n distinct integers in the ascending order — the distance from Kefa's start to each barrier in the order of its appearance. All integers are in the range from 0 to L - 1 inclusively.

The second line contains n distinct integers in the ascending order — the distance from Sasha's start to each barrier in the order of its overcoming. All integers are in the range from 0 to L - 1 inclusively.


-----Output-----

Print "YES" (without quotes), if Kefa and Sasha ran the coinciding tracks (it means that the position of all barriers coincides, if they start running from the same points on the track). Otherwise print "NO" (without quotes).


-----Examples-----
Input
3 8
2 4 6
1 5 7

Output
YES

Input
4 9
2 3 5 8
0 1 3 6

Output
YES

Input
2 4
1 3
1 2

Output
NO



-----Note-----

The first test is analyzed in the statement.

Difficulty: EASY

Solutions:
def sublistExists(list1, list2):
	return ''.join(map(str, list2)) in ''.join(map(str, list1))
(n, l) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
(a1, a2) = ([], [])
for i in range(1, n):
	a1.append(l1[i] - l1[i - 1])
	a2.append(l2[i] - l2[i - 1])
a1.append(l - l1[n - 1] + l1[0])
a2.append(l - l2[n - 1] + l2[0])
a1 += a1
if sublistExists(a1, a2) == True:
	print('YES')
else:
	print('NO')


(n, l) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
aa = [0] * n
bb = [0] * n
aa[0] = l - a[-1] + a[0]
bb[0] = l - b[-1] + b[0]
for i in range(1, n):
	aa[i] = a[i] - a[i - 1]
	bb[i] = b[i] - b[i - 1]
for i in range(n):
	if aa == bb:
		print('YES')
		break
	aa.append(aa[0])
	aa.pop(0)
else:
	print('NO')


(n, l) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
for move in range(n):
	a = a[1:] + [a[0]]
	for q in range(105):
		good = 1
		for i in range(n):
			if (a[i] + q) % l != b[i]:
				good = 0
				break
		if good:
			print('YES')
			exit()
print('NO')


class CodeforcesTask761BSolution:

	def __init__(self):
		self.result = ''
		self.n_l = []
		self.track1 = []
		self.track2 = []

	def read_input(self):
		self.n_l = [int(x) for x in input().split(' ')]
		self.track1 = [int(x) for x in input().split(' ')]
		self.track2 = [int(x) for x in input().split(' ')]

	def process_task(self):
		dists1 = [self.track1[x] - self.track1[x - 1] for x in range(1, self.n_l[0])]
		dists2 = [self.track2[x] - self.track2[x - 1] for x in range(1, self.n_l[0])]
		can = False
		for x in range(self.n_l[0]):
			nd = self.track1[x:] + self.track1[:x]
			dists1 = [nd[x] - nd[x - 1] for x in range(1, self.n_l[0])]
			for x in range(1, self.n_l[0]):
				if dists1[x - 1] < 0:
					dists1[x - 1] += self.n_l[1]
			if dists1 == dists2:
				can = True
				break
		self.result = 'YES' if can else 'NO'

	def get_result(self):
		return self.result
Solution = CodeforcesTask761BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(n, l) = map(int, input().split())
k = list(map(int, input().split()))
s = list(map(int, input().split()))
ki = [k[0]]
si = [s[0]]
tmp = 0
for i in range(1, n):
	ki.append(k[i] - k[i - 1])
	si.append(s[i] - s[i - 1])
ki[0] += l - k[-1]
si[0] += l - s[-1]
if ''.join(map(str, ki * 2)).find(''.join(map(str, si))) != -1:
	print('YES')
else:
	print('NO')


(n, L) = [int(x) for x in input().split()]
t = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]
p = ''
q = ''
for x in range(n - 1):
	p += str(t[x + 1] - t[x])
p += str(t[0] + L - t[n - 1])
for x in range(n - 1):
	q += str(d[x + 1] - d[x])
q += str(d[0] + L - d[n - 1])
a = p + p
if q in a:
	print('YES')
else:
	print('NO')


(n, L) = map(int, input().split())
k = list(map(int, input().split()))
s = list(map(int, input().split()))
dk = []
ds = []
for i in range(1, len(k)):
	dk.append(k[i] - k[i - 1])
for i in range(1, len(s)):
	ds.append(s[i] - s[i - 1])
dk.append(L - k[-1] + k[0])
ds.append(L - s[-1] + s[0])
ans = False
for i in range(n):
	if dk[i:] + dk[:i] == ds:
		ans = True
		break
print('YES' if ans else 'NO')


__author__ = 'artyom'

def find_dist(n, l):
	a = read(3)
	d = [0] * n
	for i in range(n - 1):
		d[i] = a[i + 1] - a[i]
	d[n - 1] = l - a[n - 1] + a[0]
	return d

def main():
	(n, l) = read(3)
	x = find_dist(n, l)
	y = find_dist(n, l)
	for i in range(n):
		if y[i] == x[0]:
			for j in range(1, n - i):
				if y[i + j] != x[j]:
					break
			else:
				for j in range(i):
					if y[j] != x[n - i + j]:
						break
				else:
					return 1
	return 0

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s)
write(['NO', 'YES'][main()])


(n, l) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = a[0]
y = b[0]
for i in range(n):
	a[i] -= x
	b[i] -= y
cnt = 0
while a != b and cnt != n + 1:
	a = a[1:] + a[:1]
	x = a[0]
	for i in range(n):
		a[i] = (a[i] - x) % l
	cnt += 1
if a == b:
	print('YES')
else:
	print('NO')


(n, l) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b1 = False
b2 = False
i = -1
while i < l - 1 and b1 == False:
	i += 1
	for j in range(len(b)):
		b[j] += 1
		if b[j] >= l:
			b[j] -= l
	b.sort()
	b2 = False
	for j in range(n):
		if b[j] != a[j]:
			b2 = True
	if b2 == False:
		b1 = True
if b1 == False:
	print('NO')
else:
	print('YES')


(k, n) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
d = []
for i in range(k - 1):
	c += [a[i + 1] - a[i] + 1]
	d += [b[i + 1] - b[i] + 1]
c += [n - a[-1] + a[0] + 1]
d += [n - b[-1] + b[0] + 1]
for i in range(k):
	if c == d[i:] + d[:i]:
		print('YES')
		break
else:
	print('NO')


import sys
a = input().split()
n = int(a[0])
L = int(a[1])
kefa = input().split()
sasha = input().split()
kefa[0] = int(kefa[0])
sasha[0] = int(sasha[0])
s = sasha
k = kefa
s1 = s[0]
k1 = k[0]
for i in range(1, n):
	kefa[i] = int(kefa[i])
	sasha[i] = int(sasha[i])
	k[i - 1] = kefa[i] - kefa[i - 1]
	s[i - 1] = sasha[i] - sasha[i - 1]
k[n - 1] = L - kefa[n - 1] + k1
s[n - 1] = L - sasha[n - 1] + s1
for i in range(1, n):
	if k == s:
		print('YES')
		sys.exit()
	else:
		ch = s[0]
		s.pop(0)
		s.append(ch)
print('YES') if k == s else print('NO')


from sys import stdin, stdout
import cProfile, math
from collections import Counter
printHeap = str()
test = False
memory_constrained = False

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def test_print(output):
	if test:
		stdout.write(str(output) + '\n')

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def rotate(l, offset=1):
	return l[offset:] + l[:offset]
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def main():
	(n, l) = get_tuple()
	l1 = get_list()
	l2 = get_list()
	(d1, d2) = (list(), [])
	for (i, ele) in enumerate(l1):
		if i + 1 != len(l1):
			d1.append(l1[i + 1] - ele)
	d1.append(l - l1[-1] + l1[0])
	for (i, ele) in enumerate(l2):
		if i + 1 != len(l2):
			d2.append(l2[i + 1] - ele)
	d2.append(l - l2[-1] + l2[0])
	for i in range(len(d1)):
		d2 = rotate(d2)
		if d1 == d2 or (len(l1) == 1 and len(l2) == 1):
			display('YES')
			return
	display('NO')
cProfile.run('main()') if test else main()


def codeforces(L, first, second):
	a_list = []
	b_list = []
	for i in range(L):
		if i in first:
			a_list.append(1)
		else:
			a_list.append(0)
		if i in second:
			b_list.append(1)
		else:
			b_list.append(0)
	for i in range(L):
		if b_list[i:] + b_list[0:i] == a_list:
			return 'YES'
	return 'NO'
(_, L) = map(int, input().split())
first = list(map(int, input().split()))
second = list(map(int, input().split()))
print(codeforces(L, first, second))


import copy
(a, b) = map(int, input().split())
l1 = input().split()
j = 0
for i in l1:
	l1[j] = int(i)
	j += 1
l2 = input().split()
j = 0
for i in l2:
	l2[j] = int(i)
	j += 1
l3 = copy.copy(l1)
j = 0
while j <= b:
	i = 0
	while i <= a - 1:
		l3[i] = (l1[i] + j) % b
		i += 1
	l3.sort()
	if l3 == l2:
		print('YES')
		break
	j += 1
else:
	print('NO')


def list_from_input():
	return list(map(int, input().split()))

def solve(kefa, sasha, n, l):
	sasha_distance = 0
	while sasha_distance < l:
		for i in range(n):
			sasha[i] -= 1
		if sasha[0] == -1:
			del sasha[0]
			sasha.append(l - 1)
		if sasha == kefa:
			return True
		sasha_distance += 1
	return False

def main():
	(n, l) = list_from_input()
	kefa = list_from_input()
	sasha = list_from_input()
	if solve(kefa, sasha, n, l):
		print('YES')
	else:
		print('NO')

def test():
	print(solve([2, 5, 6, 7, 8], [1, 2, 3, 4, 8], 5, 10))
main()


(k, l) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def solve():
	for i in range(l):
		if a == sorted(((x + i) % l for x in b)):
			return 'YES'
	return 'NO'
print(solve())


nl = list(map(int, input().split()))
n = nl[0]
l = nl[1]
a = list(map(int, input().split()))
dist1 = [0 for i in range(0, len(a))]
dist1[0] = l - a[len(a) - 1] + a[0]
for i in range(1, n):
	dist1[i] = a[i] - a[i - 1]
a = list(map(int, input().split()))
dist2 = [0 for i in range(0, len(a))]
dist2[0] = l - a[len(a) - 1] + a[0]
for i in range(1, n):
	dist2[i] = a[i] - a[i - 1]
res = 'NO'
if dist1 == dist2 and sum(dist1) == l:
	res = 'YES'
else:
	for j in range(1, n):
		k = dist1[len(dist1) - 1]
		for i in range(1, n + 1):
			dist1[n - i] = dist1[n - i - 1]
		dist1[0] = k
		if dist1 == dist2 and sum(dist1) == l:
			res = 'YES'
print(res)


from collections import deque
(n, L) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

def diff_vec(x):
	y = deque([(x[i % n] - x[(i - 1) % n]) % L for i in range(n)])
	return y

def compare_two_deque(x, y):
	for i in range(n):
		if x[i] != y[i]:
			return False
	return True
a = diff_vec(a)
b = diff_vec(b)
for i in range(n):
	tmp = a.popleft()
	a.append(tmp)
	if compare_two_deque(a, b):
		print('YES')
		break
	if i == n - 1:
		print('NO')


(n, L) = map(int, input().split())
Kef = list(map(int, input().split()))
Sas = list(map(int, input().split()))
dKef = [Kef[i + 1] - Kef[i] for i in range(n - 1)]
dKef.append(L - Kef[n - 1] + Kef[0])
dSas = [Sas[i + 1] - Sas[i] for i in range(n - 1)]
dSas.append(L - Sas[n - 1] + Sas[0])
if ' '.join(map(str, dKef)) in ' '.join(map(str, dSas * 2)):
	print('YES')
else:
	print('NO')


(n, L) = [int(el) for el in input().split()]
P1 = [int(el) for el in input().split()]
P2 = [int(el) for el in input().split()]
p1 = [0] * n
p2 = [0] * n
p1[0] = P1[0] + L - P1[-1]
p2[0] = P2[0] + L - P2[-1]
for i in range(1, n):
	p1[i] = P1[i] - P1[i - 1]
	p2[i] = P2[i] - P2[i - 1]
ans = False
for i in range(n):
	i2 = i
	j = 0
	while j < n and p1[i2] == p2[j]:
		i2 = (i2 + 1) % n
		j += 1
	if j == n:
		ans = True
		break
if ans:
	print('YES')
else:
	print('NO')


import math
import itertools
import sys
import collections
import bisect
from decimal import *
files = False
if files:
	name = 'factorial'
	sys.stdin = open('input.txt')
	sys.stdout = open('output.txt', mode='w')

def ria():
	return [int(i) for i in input().split()]

def bin_s(xp, xc, yc, rc):
	rc **= 2
	r = yc + rc
	l = yc
	while l + 1 < r:
		m = (l + r) // 2
		if (xp - xc) ** 2 + (m - yc) ** 2 > rc:
			r = m
		elif (xp - xc) ** 2 + (1 + m - yc) ** 2 <= rc:
			l = m
		else:
			return m - yc
	if abs(complex(xp - xc, r - yc)):
		return r - yc
	else:
		return l - yc
(n, l) = ria()
ar1 = ria()
ar2 = ria()
canBe = [i for i in range(l)]
for i in range(l):
	bad = False
	for j in range(n):
		if ar1[j] != ar2[j]:
			bad = True
			break
	if not bad:
		print('YES')
		exit(0)
	ar2 = [(j + 1) % l for j in ar2]
	ar2 = [j for j in sorted(ar2)]
print('NO')
sys.stdout.close()


(n, l) = map(int, input().split())
k = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
for i in range(1, n):
	k[i] -= k[0]
k[0] = 0
c = 0
for i in range(l):
	ci = c
	flag = True
	for j in range(n):
		if k[ci] < i:
			if s[j] != l - (i - k[ci]):
				flag = False
				break
		elif s[j] != k[ci] - i:
			flag = False
			break
		ci = (ci + 1) % n
	if flag:
		print('YES')
		exit(0)
	if i == k[c]:
		c = (c + 1) % n
print('NO')


(n, l) = map(int, input().split())
track1 = list(map(int, input().split()))
track2 = list(map(int, input().split()))
a = [0] * l
b = [0] * l
for i in range(n):
	a[track1[i]] = 1
	b[track2[i]] = 1
for i in range(l):
	b.insert(0, b.pop())
	if b == a:
		print('YES')
		exit(0)
print('NO')


(n, l) = map(int, input().split())
kefa = list(map(int, input().split()))
sasha = list(map(int, input().split()))
diff1 = [kefa[i + 1] - kefa[i] if i != n - 1 else l - kefa[-1] + kefa[0] for i in range(n)]
diff2 = [sasha[i + 1] - sasha[i] if i != n - 1 else l - sasha[-1] + sasha[0] for i in range(n)]

def rotation(pos):
	for i in range(n):
		if diff2[(i + pos) % n] != diff1[i]:
			return False
	return True
for i in range(n):
	if rotation(i):
		print('YES')
		exit()
print('NO')


(n, L) = [int(item) for item in input().split()]
k = [int(item) for item in input().split()]
s = [int(item) for item in input().split()]
k0 = []
for i in range(n - 1):
	k0.append(k[i + 1] - k[i])
k0.append(L - sum(k0))
s0 = []
for i in range(n - 1):
	s0.append(s[i + 1] - s[i])
s0.append(L - sum(s0))
for i in range(n):
	if s0[i:] + s0[:i] == k0:
		print('YES')
		break
else:
	print('NO')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l1 = list(map(int, input().split()))
k1 = []
k2 = []
for i in range(n - 1):
	k1.append(l[i + 1] - l[i])
	k2.append(l1[i + 1] - l1[i])
k1.append(m - l[n - 1] + l[0])
k2.append(m - l1[n - 1] + l1[0])
g = [1, 2, 3, 4]
for i in range(n):
	p = k1[i + 1:n] + k1[:i + 1]
	if p == k2:
		print('YES')
		exit()
print('NO')


[n, L] = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(L):
	a2 = list(a)
	for j in range(n):
		a2[j] = (a2[j] + i) % L
	a2.sort()
	if a2 == b:
		print('YES')
		exit(0)
print('NO')


def calc_distances(points):
	distances = [0] * n
	for i in range(n):
		dist = points[i] - points[i - 1]
		if dist < 0:
			dist += length
		distances[i] = dist
	return distances

def rotate(lst, i):
	return lst[i:] + lst[:i]
(n, length) = list(map(int, input().split()))
(a, b) = [calc_distances(list(map(int, input().split()))) for i in range(2)]
for i in range(n):
	if b[i] == a[0] and rotate(b, i) == a:
		print('YES')
		break
else:
	print('NO')


(n, L) = [int(x) for x in input().strip().split()]
k = [int(x) for x in input().strip().split()]
s = [int(x) for x in input().strip().split()]
old_s = s[:]
ans = False
first_spin = True
while s != old_s or first_spin:
	first_spin = False
	for i in range(len(s)):
		s[i] -= 1
	if s[0] == -1:
		del s[0]
		s.append(L - 1)
	if s == k:
		ans = True
		break
if not ans:
	print('NO')
else:
	print('YES')


(n, L) = [int(x) for x in input().split()]
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s1 = a[n - 1]
s2 = b[n - 1]
x1 = L - s1
x2 = L - s2
c = []
d = []
c.append(a[0] + x1)
d.append(b[0] + x2)
for i in range(n - 1):
	c.append(a[i + 1] - a[i])
	d.append(b[i + 1] - b[i])
for i in range(n):
	k = True
	for j in range(n):
		if c[j] != d[(j + i) % n]:
			k = False
	if k:
		print('YES')
		return
print('NO')


(n, L) = map(int, input().split())
if n == 1:
	print('YES')
	exit(0)
first = list(map(int, input().split()))
second = list(map(int, input().split()))

def shift(lst, value):
	for i in range(len(lst)):
		lst[i] -= value
	return lst

def equal(lst1, lst2):
	for i in range(len(lst1)):
		if lst1[i] != lst2[i]:
			return False
	return True
first = shift(first, first[0])
second = shift(second, second[0])
for i in range(n):
	first = shift(first, first[1])
	first = first[1:] + [L + first[0]]
	if equal(first, second):
		print('YES')
		exit(0)
print('NO')


(b, l) = map(int, input().split())
k = list(map(int, input().split()))
s = list(map(int, input().split()))
c = 0
i = -1
while s != k and c == 0:
	i = i + 1
	for j in range(len(s)):
		s[j] = s[j] - 1
		if s[j] < 0:
			s[j] = l - 1
	s.sort()
	if i == l:
		c = 1
if s != k and c == 1:
	print('NO')
if s == k and c == 0:
	print('YES')


(n, L) = [int(x) for x in input().split()]
l1 = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
d1 = [0] * n
d2 = [0] * 2 * n
(s1, s2) = (0, 0)
(st1, st2) = ('', '')
for i in range(n - 1):
	d1[i] = l1[i + 1] - l1[i]
	d2[i] = l2[i + 1] - l2[i]
	s1 += d1[i]
	s2 += d2[i]
d1[n - 1] = L - s1
d2[n - 1] = L - s2
for i in range(n):
	d2[i + n] = d2[i]
	st1 += str(d1[i])
for i in range(2 * n):
	st2 += str(d2[i])
if st1 in st2:
	print('YES')
else:
	print('NO')


import math
if 1:
	(n, l) = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	diff1 = []
	for i in range(n - 1):
		diff1.append(abs(l1[i + 1] - l1[i]))
	diff1.append(l - l1[-1] + l1[0])
	diff2 = []
	for j in range(n - 1):
		diff2.append(abs(l2[j + 1] - l2[j]))
	diff2.append(l - l2[-1] + l2[0])
	x = ' '.join(map(str, diff1)) in ' '.join(map(str, diff2 * 2))
	if x:
		print('YES')
	else:
		print('NO')


(n, L) = map(int, input().split())
k = list(map(int, input().split()))
s = list(map(int, input().split()))
for i in range(len(k)):
	ts = s[i:] + s[:i]
	diff = lambda i: (ts[i] - k[i]) % L
	if all((diff(i) == diff(0) for i in range(len(k)))):
		print('YES')
		exit()
print('NO')


(n, L) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(len(b)):
	c = b[i:] + b[:i]
	d = map(lambda x, y: abs(x - y), a, c)
	s = set(d)
	if len(s) == 2 and sum(s) == L or len(s) == 1:
		print('YES')
		exit(0)
print('NO')


def Main():
	(n, l) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	L = []
	ans = False
	cnt = 0
	for i in range(l):
		c = sorted(list(map(lambda x: (x + i) % l, B)))
		if c == A:
			ans = True
			cnt += 1
	if ans:
		print('YES')
	else:
		print('NO')
Main()


(n, l) = map(int, input().split())
if n == 1:
	print('YES')
	exit()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
i1 = 0
for i in range(1, n + 1):
	if i % n != 0:
		if abs(a[i % n] - a[(i - 1) % n]) == b[1] - b[0]:
			i1 = (i - 1) % n + 1
			for j in range(1, n + 1):
				if i1 % n != 0:
					if j % n != 0:
						if abs(a[i1 % n] - a[(i1 - 1) % n]) == abs(b[j % n] - b[(j - 1) % n]):
							i1 += 1
							if j == n:
								print('YES')
								exit()
						else:
							break
					elif abs(a[i1 % n] - a[(i1 - 1) % n]) == abs(b[0] + l - b[(j - 1) % n]):
						i1 += 1
						if j == n:
							print('YES')
							exit()
						else:
							break
				elif j % n != 0:
					if abs(a[i1 % n] + l - a[(i1 - 1) % n]) == abs(b[j % n] - b[(j - 1) % n]):
						i1 += 1
						if j == n:
							print('YES')
							exit()
					else:
						break
				elif abs(a[i1 % n] + l - a[(i1 - 1) % n]) == abs(b[0] + l - b[(j - 1) % n]):
					i1 += 1
					if j == n:
						print('YES')
						exit()
					else:
						break
	elif abs(a[i % n] + l - a[(i - 1) % n]) == b[1] - b[0]:
		i1 = (i - 1) % n + 1
		for j in range(1, n + 1):
			if i1 % n != 0:
				if j % n != 0:
					if abs(a[i1 % n] - a[(i1 - 1) % n]) == abs(b[j % n] - b[(j - 1) % n]):
						i1 += 1
						if j == n:
							print('YES')
							exit()
					else:
						break
				elif abs(a[i1 % n] - a[(i1 - 1) % n]) == abs(b[0] + l - b[(j - 1) % n]):
					i1 += 1
					if j == n:
						print('YES')
						exit()
					else:
						break
			elif j % n != 0:
				if abs(a[i1 % n] + l - a[(i1 - 1) % n]) == abs(b[j % n] - b[(j - 1) % n]):
					i1 += 1
					if j == n:
						print('YES')
						exit()
				else:
					break
			elif abs(a[i1 % n] + l - a[(i1 - 1) % n]) == abs(b[0] + l - b[(j - 1) % n]):
				i1 += 1
				if j == n:
					print('YES')
					exit()
				else:
					break
print('NO')


(q, w) = map(int, input().split())
a = list(map(int, input().split()))
s = list(map(int, input().split()))
z = [0] * q
for i in range(1, q):
	z[i] = a[i] - a[i - 1]
z[0] = w - a[q - 1] + a[0]
z = z + z + z
x = [0] * q
for i in range(1, q):
	x[i] = s[i] - s[i - 1]
x[0] = w - s[q - 1] + s[0]
b = False
for i in range(0, q + 1):
	if z[i:i + q] == x:
		b = True
if b:
	print('YES')
else:
	print('NO')


(n, l) = map(int, input().split())
trek1 = list(map(int, input().split()))
trek2 = set(list(map(int, input().split())))

def one(a, x):
	return [(i + x) % l for i in a]
ans = 'NO'
for i in range(l):
	if set(one(trek1, i)) == trek2:
		ans = 'YES'
		break
print(ans)


from collections import *
from math import *
from itertools import *
import os
import sys
from io import BytesIO, IOBase

def main():
	(n, L) = map(int, input().split())
	Keta = list(map(int, input().split()))
	Sasha = list(map(int, input().split()))
	for rotation in range(L):
		route = []
		for barrier in Keta:
			route.append((barrier + rotation) % L)
		route.sort()
		if route == Sasha:
			print('YES')
			return
	print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def main():
	(n, l) = map(int, input().split())
	aa = list(map(int, input().split()))
	bb = list(map(int, input().split()))
	for (i, a) in enumerate(aa, -n):
		a -= bb[0]
		if all((aa[j] == (a + b) % l for (j, b) in enumerate(bb, i))):
			print('YES')
			return
	print('NO')
main()


(n, d) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
a = list(map(lambda x: x - a[0], a))
b = list(map(lambda x: x - b[0], b))
isTrue = False
for i in range(n + 1):
	if a == b:
		isTrue = True
		break
	else:
		b.pop(0)
		t = b[0]
		b = list(map(lambda x: x - b[0], b))
		b.append(d - t)
if isTrue:
	print('YES')
else:
	print('NO')


(a, n) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
dist1 = []
dist2 = []
for i in range(1, a):
	dist1.append(x[i] - x[i - 1])
	dist2.append(y[i] - y[i - 1])
dist1.append(n - sum(dist1))
dist2.append(n - sum(dist2))
for start in range(len(dist1)):
	bool = True
	for i in range(start, len(dist1)):
		if dist1[i] != dist2[i - start]:
			bool = False
	dist1.append(dist1[start])
	if bool:
		break
if bool:
	print('YES')
else:
	print('NO')


(n, L) = map(int, input().split())
l_x = list(map(int, input().split()))
l_x.sort()
l_y = list(map(int, input().split()))
for i in range(L):
	for j in range(n):
		l_y[j] = (l_y[j] + 1) % L
	l_y = sorted(l_y)
	if sorted(l_y) == l_x:
		print('YES')
		quit()
print('NO')


(n, l) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(0, l):
	s = set()
	cnt = 0
	for j in a:
		s.add((i + j) % l)
	for j in range(0, l):
		cnt = 0
		for k in b:
			if (j + k) % l in s:
				cnt += 1
		if cnt == n:
			print('YES')
			exit(0)
print('NO')


import sys

def debug(x, table):
	for (name, val) in table.items():
		if x is val:
			print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
			return None

def solve():
	(n, L) = map(int, input().split())
	A = [int(i) for i in input().split()]
	B = [int(i) for i in input().split()]
	for i in range(L):
		B = [(b + 1) % L for b in B]
		if B[-1] == 0:
			B = [B[-1]] + B[:-1]
		if A == B:
			print('YES')
			return None
	else:
		print('NO')
solve()


from collections import deque
(n, L) = list(map(int, input().split()))
d1 = [int(i) for i in input().split()]
d2 = deque([int(i) for i in input().split()])
ans = False
if n == 1:
	ans = True
for i in range(n):
	if ans:
		break
	diff = (d1[0] - d2[0]) % L
	fl = True
	for j in range(n):
		if (d1[j] - d2[j]) % L != diff:
			fl = False
	if fl:
		ans = True
	d2.rotate(1)
print(['NO', 'YES'][ans])


def reverse(i, j, A):
	while i < j:
		(A[i], A[j]) = (A[j], A[i])
		i += 1
		j -= 1
(N, L) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
same = False
track = []
for l in range(L):
	for n in range(N):
		A[n] = (A[n] + 1) % L
	p = N - 1
	for n in range(N - 1):
		if A[n] > A[n + 1]:
			p = n
	reverse(0, p, A)
	reverse(0, N - 1, A)
	if A == B:
		same = True
if same:
	print('YES')
else:
	print('NO')


(n, L) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(a0, b0) = (a[0], b[0])
for i in range(n - 1):
	a[i] = a[i + 1] - a[i]
	b[i] = b[i + 1] - b[i]
a[-1] = a0 - a[-1] + L
b[-1] = b0 - b[-1] + L
t = False
for start in range(n):
	if a == b[start:] + b[:start]:
		t = True
if t:
	print('YES')
else:
	print('NO')


(n, l) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(l):
	for j in range(n):
		a[j] = (a[j] + 1) % l
	a.sort()
	if a == b:
		print('YES')
		break
else:
	print('NO')


import sys, string
(n, l) = [int(x) for x in sys.stdin.readline().split()]

def offsets_str():
	dists = [int(x) for x in sys.stdin.readline().split()]
	offsets = [dists[i] - dists[i - 1 % n] for i in range(n)]
	offsets_norm = [x if x >= 0 else l + x for x in offsets]
	return ''.join(map(str, offsets_norm))
kefas = offsets_str()
sashas = offsets_str()
print('YES' if kefas in sashas + sashas else 'NO')


(n, l) = list(map(int, input().strip().split()))
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
f = 0
for i in range(l):
	c = []
	for j in range(n):
		c.append((i + B[j]) % l)
	c.sort()
	if c == A:
		f = 1
if f:
	print('YES')
else:
	print('NO')


(n, L) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for b in range(L):
	C = []
	for x in A:
		C.append((x - b) % L)
	if sorted(C) == B:
		print('YES')
		exit(0)
print('NO')


(n, l) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
double_break = False
for starta in range(l):
	track1 = [0] * l
	track2 = [0] * l
	for i in range(n):
		track1[(starta + a[i]) % l] = 1
	for startb in range(l):
		for j in range(n):
			track2[(startb + b[j]) % l] = 1
		if track1 == track2:
			print('YES')
			double_break = True
			break
	if double_break:
		break
else:
	print('NO')


(n, l) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [0] * n
d = [0] * n
for i in range(n - 1):
	c[i] = a[i + 1] - a[i]
c[n - 1] = l - sum(c)
for i in range(n - 1):
	d[i] = b[i + 1] - b[i]
d[n - 1] = l - sum(d)
f = False
for i in range(0, n):
	if d == c[i:n] + c[:i]:
		f = True
if f:
	print('YES')
else:
	print('NO')


(n, L) = tuple([int(x) for x in input().split()])
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
for i in range(L):
	if a == b:
		print('YES')
		break
	if b[n - 1] + 1 >= L:
		b = [0] + [x + 1 for x in b[0:-1]]
	else:
		b = [x + 1 for x in b[:]]
else:
	print('NO')


(n, l) = map(int, input().split())
l1 = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
s1 = ''
prev = -1
for i in range(n):
	s1 += '0' * (l1[i] - prev - 1) + '1'
	prev = l1[i]
s1 += '0' * (l - prev - 1)
s2 = ''
prev = -1
for i in range(n):
	s2 += '0' * (l2[i] - prev - 1) + '1'
	prev = l2[i]
s2 += '0' * (l - prev - 1)
s1 = s1 * 2
if s1.find(s2) != -1:
	print('YES')
else:
	print('NO')


read = lambda : map(int, input().split())
(n, L) = read()
a = list(read())
b = list(read())
for j in range(n):
	dif = [(a[i] - b[(i + j) % n]) % L for i in range(n)]
	if len(set(dif)) == 1:
		print('YES')
		exit()
print('NO')


import math, sys

def main():
	(n, l) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	mask = []
	for i in range(n - 1):
		mask.append(a[i + 1] - a[i])
	mask.append(l - a[n - 1] + a[0])
	b = list(map(int, input().split()))
	path = []
	for i in range(n - 1):
		path.append(b[i + 1] - b[i])
	path.append(l - b[n - 1] + b[0])
	for offset in range(n):
		flag = True
		for i in range(n):
			if mask[(i + offset) % n] != path[i]:
				flag = False
				break
		if flag:
			print('YES')
			return
	print('NO')

def __starting_point():
	main()
__starting_point()


(n, L) = map(int, input().split(' '))
Karr = list(map(int, input().split(' ')))
Sarr = list(map(int, input().split(' ')))
Kdiff = []
Sdiff = []
for i in range(n - 1):
	Kdiff.append(Karr[i + 1] - Karr[i])
	Sdiff.append(Sarr[i + 1] - Sarr[i])
Kdiff.append(Karr[0] + L - Karr[-1])
Sdiff.append(Sarr[0] + L - Sarr[-1])
Kdiff2 = Kdiff + Kdiff
if ''.join(map(str, Sdiff)) in ''.join(map(str, Kdiff2)):
	print('YES')
else:
	print('NO')


(n, l) = input().split()
(n, l) = (int(n), int(l))
l1 = [int(x) for x in input().split()]
l2 = [int(y) for y in input().split()]
l1 = l1 + [l]
l2 = l2 + [l]
bl1 = []
bl2 = []
for i in range(len(l1) - 1):
	d = l1[i + 1] - l1[i]
	bl1.append(d)
for i in range(len(l2) - 1):
	p = l2[i + 1] - l2[i]
	bl2.append(p)
bl1[n - 1] = bl1[n - 1] + l1[0]
bl2[n - 1] = bl2[n - 1] + l2[0]
for i in range(n):
	bl1 = [bl1[n - 1]] + bl1[:n - 1]
	if bl1 == bl2:
		print('YES')
		break
else:
	print('NO')


(n, l) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = []
y = []
x.append(a[0] + l - a[n - 1])
for i in range(1, n):
	x.append(a[i] - a[i - 1])
y.append(b[0] + l - b[n - 1])
for i in range(1, n):
	y.append(b[i] - b[i - 1])
for i in range(n):
	k = i
	c = True
	for j in range(n):
		if k == n:
			k = 0
		if x[k] != y[j]:
			c = False
			break
		k += 1
	if c == True:
		print('YES')
		exit(0)
print('NO')


import math, re, itertools as it
prime = lambda n: len([i for i in range(2, int(math.sqrt(n) + 1)) if n % i == 0]) == 0
gcd = lambda a, b: gcd(b, a % b) if b else a
fact = lambda x: x * fact(x - 1) if x else 1
bino = lambda n, k: fact(n) / fact(k) / fact(n - k)
fib11 = lambda n: 1 if n < 2 else fib11(n - 1) + fib11(n - 2)
fib01 = lambda n: 0 if n == 0 else 1 if n == 1 else fib01(n - 1) + fib01(n - 2)
sumofd = lambda x: x if x < 10 else sumofd(x // 10) + x % 10
(n, l) = map(int, input().split(' '))
k = list(map(int, input().split()))
s = list(map(int, input().split()))
f = False
for i in range(l):
	for j in range(len(k)):
		k[j] -= 1
		if k[j] < 0:
			k[j] = l - 1
	k.sort()
	if k == s:
		f = True
print('YES' if f else 'NO')


(n, l) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(l):
	if a == b:
		break
	else:
		a = list(map(lambda x: x + 1, a))
	if a[n - 1] == l:
		a.pop(n - 1)
		a.insert(0, 0)
if a == b:
	print('YES')
else:
	print('NO')


(n, l) = map(int, input().split())
f1 = [0] * l
f2 = [0] * l
for x in list(map(int, input().split())):
	f1[x] = 1
for x in list(map(int, input().split())):
	f2[x] = 1
for _ in range(l + 1):
	f1 = f1[1:] + [f1[0]]
	if f1 == f2:
		print('YES')
		break
else:
	print('NO')


def normalize(l, d):
	res = [l[i] - l[i - 1] for i in range(1, n)]
	res.append(d - l[-1] + l[0])
	return res
(n, l) = map(int, input().split())
a = normalize([*map(int, input().split())], l)
b = normalize([*map(int, input().split())], l)
print('YES' if any((a[i:] + a[:i] == b for i in range(n))) else 'NO')


(n, l) = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
first_diff = A[0]
A = [x - first_diff for x in A]
first_diff = B[0]
B = [x - first_diff for x in B]
found = False
for _ in range(n + 2):
	if A == B:
		found = True
	B = B[1:] + [B[0] + l]
	first_diff = B[0]
	B = [x - first_diff for x in B]
if found:
	print('YES')
else:
	print('NO')


(n, l) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
a = []
for i in range(n - 1):
	a += [x[i + 1] - x[i]]
a += [l - x[n - 1] + x[0]]
b = []
for i in range(n - 1):
	b += [y[i + 1] - y[i]]
b += [l - y[n - 1] + y[0]]
ans = 0
for i in range(n):
	t = b[i:] + b[:i]
	if t == a:
		ans = 1
		break
if ans == 1:
	print('YES')
else:
	print('NO')


def myf(n, L, mass1, mass2):
	if n == 1:
		return 'YES'
	else:
		dist1 = [0 for i in range(n)]
		dist2 = [0 for i in range(n)]
		for i in range(n - 1):
			dist1[i] = mass1[i + 1] - mass1[i]
		dist1[-1] = mass1[0] + L - mass1[n - 1]
		for i in range(n - 1):
			dist2[i] = mass2[i + 1] - mass2[i]
		dist2[-1] = mass2[0] + L - mass2[n - 1]
		for each in range(n):
			if dist1 == dist2:
				return 'YES'
			else:
				c = dist2[-1]
				dist2.pop()
				dist2.insert(0, c)
		return 'NO'
(n, L) = map(int, input().split())
mass1 = list(map(int, input().split()))
mass2 = list(map(int, input().split()))
print(myf(n, L, mass1, mass2))


from sys import stdin, stdout
from functools import partial
ONLINE_JUDGE = 1
if ONLINE_JUDGE:
	inp = stdin
	out = stdout
else:
	inp = open('input.txt', 'r')
	out = open('output.txt', 'w')
print_f = partial(print, file=out)
(n, l) = [int(i) for i in inp.readline().split()]
f = [int(i) for i in inp.readline().split()]
s = [int(i) for i in inp.readline().split()]
for p in range(n):
	diffs = [(l + f[i] - s[(i + p) % n]) % l for i in range(n)]
	if diffs.count(diffs[0]) == len(diffs):
		print_f('YES')
		exit()
print_f('NO')


(n, l) = map(int, input().split(' '))
if n == 1:
	print('YES')
else:
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a = a + a[:-1]
	found = False
	for i in range(n):
		flag = True
		for j in range(n - 1):
			k = i + j
			diff_a = a[k + 1] - a[k] if a[k + 1] > a[k] else a[k + 1] + l - a[k]
			if b[j + 1] - b[j] != diff_a:
				flag = False
				break
		if flag:
			found = True
			break
	print('YES' if found else 'NO')


(n, l) = map(int, input().split())
d1 = list(map(int, input().split()))
d2 = list(map(int, input().split()))
flag = False
for i in range(l):
	for j in range(n):
		d1[j] -= 1
		if d1[j] == -1:
			d1[j] = l - 1
	d1.sort()
	if d1 == d2:
		flag = True
if flag:
	print('YES')
else:
	print('NO')


from sys import stdin, stdout
(n, l) = map(int, stdin.readline().split())
rang1 = list(map(int, stdin.readline().split()))
rang2 = list(map(int, stdin.readline().split()))
for i in range(n):
	for j in range(n):
		if (rang2[(j + 1) % n] + l - rang2[j]) % l != (rang1[(j + 1 + i) % n] + l - rang1[(j + i) % n]) % l:
			break
	else:
		stdout.write('YES')
		break
else:
	stdout.write('NO')


(n, L) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(na, nb) = ([], [])
for x in range(n - 1):
	na.append(a[x + 1] - a[x])
	nb.append(b[x + 1] - b[x])
na.append(L - a[-1] + a[0])
nb.append(L - b[-1] + b[0])
ret = False
for x in range(n):
	if na == nb:
		ret = True
		break
	c = na.pop()
	na.insert(0, c)
if ret == True:
	print('YES')
else:
	print('NO')


(b, l) = map(int, input().split())
z = list(map(int, input().split()))
z1 = list(map(int, input().split()))
(c, c1) = ([], [])
for i in range(b - 1):
	c.append(z[i + 1] - z[i])
	c1.append(z1[i + 1] - z1[i])
c.append(l - z[-1] + z[0])
c1.append(l - z1[-1] + z1[0])
c = 2 * c
for i in range(b):
	ok = True
	for j in range(b):
		if c[i + j] != c1[j]:
			ok = False
	if ok:
		exit(print('YES'))
print('NO')


import sys
(n, l) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ax = []
ax.append(a[0] + (l - 1 - a[-1]) + 1)
for i in range(1, n):
	ax.append(a[i] - a[i - 1])
bx = []
bx.append(b[0] + (l - 1 - b[-1]) + 1)
for i in range(1, n):
	bx.append(b[i] - b[i - 1])
for i in range(0, n):
	if ax == bx[i:] + bx[:i]:
		print('YES')
		sys.exit()
print('NO')


(n, L) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
s1 = []
for i in range(n - 1):
	s1.append(l1[i + 1] - l1[i])
s1.append(l1[0] + L - l1[n - 1])
S1 = []
S1.append(s1)
for i in range(1, n):
	S1.append(s1[i:] + s1[:i])
s2 = []
for i in range(n - 1):
	s2.append(l2[i + 1] - l2[i])
s2.append(l2[0] + L - l2[n - 1])
try:
	idx = S1.index(s2)
	print('YES')
except:
	print('NO')


import sys
from collections import deque
read = lambda : sys.stdin.readline().strip()
write = lambda x: sys.stdout.write(x + '\n')

def compare(a, b, N):
	for i in range(N):
		if a[i] != b[i]:
			return False
	return True
(n, L) = map(int, read().split())
kefa = [int(k) for k in read().split()]
sasha = [int(s) for s in read().split()]
(kis, sis) = (deque(), [])
for i in range(n):
	if i == n - 1:
		kis.append(L - kefa[n - 1] + kefa[0])
		sis.append(L - sasha[n - 1] + sasha[0])
	else:
		kis.append(kefa[i + 1] - kefa[i])
		sis.append(sasha[i + 1] - sasha[i])
cnt = 0
while True:
	if cnt == n:
		ans = 'NO'
		break
	if not compare(kis, sis, n):
		kis.append(kis.popleft())
		cnt += 1
		continue
	else:
		ans = 'YES'
		break
write(ans)


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
for _ in range(n):
	a = a[1:] + [a[0]]
	for q in range(105):
		for i in range(n):
			if (a[i] + q) % k != b[i]:
				break
		else:
			print('YES')
			exit()
print('NO')


(n, L) = list(map(lambda x: int(x), input().split()))
k = list(map(lambda x: int(x), input().split()))
s = list(map(lambda x: int(x), input().split()))
j = 1
flag = False
for i in range(L):
	for x in range(n):
		s[x] += 1
		if s[x] == L:
			s[x] = 0
	for x in range(n):
		s = s[1:] + [s[0]]
		if k == s:
			print('YES')
			j = 0
			flag = True
			break
	if flag:
		break
if j == 1:
	print('NO')


(n, l) = map(int, input().split())
x = [int(q) for q in input().split()]
y = [int(w) for w in input().split()]
a = 0
for i in range(l):
	r = []
	for j in range(len(x)):
		r.append((i + x[j]) % l)
	if sorted(r) == y:
		a += 1
if a == 0:
	print('NO')
else:
	print('YES')


def shift(seq, n):
	return seq[n:] + seq[:n]
(n, l) = [int(x) for x in input().split(' ')]
temp = 0
temp = [int(x) for x in input().split(' ')]
prev = temp[0]
a = []
for i in temp[1:]:
	a.append(i - prev)
	prev = i
a.append(l - temp[n - 1] + temp[0])
b = []
temp = [int(x) for x in input().split(' ')]
prev = temp[0]
for i in temp[1:]:
	b.append(i - prev)
	prev = i
b.append(l - temp[n - 1] + temp[0])
flag = 0
for i in range(n):
	if a == b:
		print('YES')
		flag = 1
		break
	a = shift(a, 1)
if flag == 0:
	print('NO')


(n, L) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
c = []
d = []
for i in range(L):
	if a != b:
		for j in range(n):
			if a[j] > 0:
				a[j] -= 1
			else:
				a[j] = L - 1
	else:
		break
	a.sort()
if a == b:
	print('YES')
else:
	print('NO')


pocty = list(map(int, input().split()))
n = pocty[0]
L = pocty[1]
k = list(map(int, input().split()))
s = list(map(int, input().split()))
for i in range(n):
	bazmek = (k[0] - s[i]) % L
	for j in range(n):
		pomocna = (i + j) % n
		if (k[j] - s[pomocna]) % L != bazmek:
			break
		if j == n - 1:
			print('YES')
			exit()
print('NO')


(n, l) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans1 = [0] * n
ans2 = [0] * n
for j in range(n):
	if j == 0:
		ans1[j] = A[j] + (l - A[-1 - j])
		ans2[j] = B[j] + (l - B[-1 - j])
	else:
		ans1[j] = A[j] - A[j - 1]
		ans2[j] = B[j] - B[j - 1]
per = 0
for j in range(n):
	if ans1 == ans2:
		per = 1
		break
	else:
		s = ans1[0]
		ans1 = ans1[1:]
		ans1.append(s)
if per == 1:
	print('YES')
else:
	print('NO')


input1 = list(map(int, input().split()))
K = list(map(int, input().split()))
S = list(map(int, input().split()))
n = input1[0]
l = input1[1]
Klist = []
for i in range(1, len(K)):
	Klist.append(K[i] - K[i - 1])
max = 0
for i in range(0, len(Klist)):
	max += Klist[i]
Klist.append(l - max)
Slist = []
for i in range(1, len(S)):
	Slist.append(S[i] - S[i - 1])
max = 0
for i in range(0, len(Slist)):
	max += Slist[i]
Slist.append(l - max)
count = 0
T = False
while count < len(Klist) + 1:
	if Slist == Klist:
		T = True
		break
	else:
		count += 1
		vars = Klist.pop(0)
		Klist.append(int(vars))
if T:
	print('YES')
else:
	print('NO')


(a, L) = map(int, input().split())
K = list(map(int, input().split()))
S = list(map(int, input().split()))
for x1 in range(0, L):
	res = True
	S1 = []
	for i in range(0, len(S)):
		if S[i] + x1 < L:
			S1.append(S[i] + x1)
		else:
			S1.append(S[i] + x1 - L)
	S1.sort()
	for i in range(0, len(S1)):
		if S1[i] != K[i]:
			res = False
			break
	if res:
		break
if res:
	print('YES')
else:
	print('NO')


def main():
	from sys import stdin, stdout
	(n, l) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	ansa = []
	ansb = []
	for i in range(1, n):
		ansa.append(a[i] - a[i - 1])
		ansb.append(b[i] - b[i - 1])
	ansa.append(a[0] + (l - a[-1]))
	ansb.append(b[0] + (l - b[-1]))
	i = -1
	flag = 0
	while i < n:
		if ansa == ansb[i + 1:] + ansb[:i + 1]:
			flag = 1
			break
		i += 1
	if flag:
		stdout.write('YES')
	else:
		stdout.write('NO')
main()


(n, l) = [int(x) for x in input().split(' ')]
k = [int(x) for x in input().split(' ')]
s = [int(x) for x in input().split(' ')]
kd = [(k[i % n] - k[i - 1]) % l for i in range(1, n + 1)]
sd = [(s[i % n] - s[i - 1]) % l for i in range(1, n + 1)]
ans = False
for i in range(n):
	if kd == sd[i:] + sd[:i]:
		ans = True
		break
if ans:
	print('YES')
else:
	print('NO')


(n, l) = tuple(map(int, input().split(' ')))

def sublist(list1, list2):
	for i in range(n):
		for j in range(n):
			if list1[i + j] != list2[j]:
				break
			elif j == n - 1:
				return True
	return False
v1 = list(map(int, input().split(' ')))
v2 = list(map(int, input().split(' ')))
(t1, t2) = ([], [])
for i in range(1, n):
	t1.append(v1[i] - v1[i - 1])
	t2.append(v2[i] - v2[i - 1])
t1.append(v1[0] + l - v1[-1])
t2.append(v2[0] + l - v2[-1])
t1 = t1 * 2
if sublist(t1, t2):
	print('YES')
else:
	print('NO')


import sys
(n, l) = input().strip().split(' ')
(n, l) = (int(n), int(l))
l1 = list(map(int, input().strip().split(' ')))
l2 = list(map(int, input().strip().split(' ')))
a1 = []
a2 = []
for i in range(1, n):
	a1.append(l1[i] - l1[i - 1])
	a2.append(l2[i] - l2[i - 1])
a1.append(l - l1[-1] + l1[0])
a2.append(l - l2[-1] + l2[0])
for i in range(n):
	lis = a1[i:] + a1[0:i]
	if lis == a2:
		print('YES')
		exit()
print('NO')


def get_diff(arr, n, l):
	diff_arr = ''
	for i in range(n - 1):
		diff = arr[i + 1] - arr[i]
		diff = min(diff, l - diff)
		diff_arr += str(diff)
	diff = arr[n - 1] - arr[0]
	diff = min(diff, l - diff)
	diff_arr += str(diff)
	return diff_arr

def is_rotation(diff1, diff2):
	diff2 += diff2
	return diff1 in diff2
(n, l) = map(int, input().split())
arr1 = [int(inp) for inp in input().split()]
arr2 = [int(inp) for inp in input().split()]
diff1 = get_diff(arr1, n, l)
diff2 = get_diff(arr2, n, l)
if is_rotation(diff1, diff2):
	print('YES')
else:
	print('NO')


(n, length) = (int(i) for i in input().split())
kef = tuple((int(i) for i in input().split()))
alex = tuple((int(i) for i in input().split()))

def divs(a, length):
	res = []
	for i in range(len(a)):
		res.append((a[i] - a[i - 1]) % length)
	return res

def check(kef, alex, length):
	kef = divs(kef, length)
	alex = divs(alex, length)
	for i in range(len(kef)):
		flag = True
		for j in range(len(kef)):
			if kef[(i + j) % len(kef)] != alex[j]:
				flag = False
				break
		if flag == True:
			return True
	return False
if check(kef, alex, length):
	print('YES')
else:
	print('NO')


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, l) = f()
l1 = il()
l2 = il()
for i in range(101):
	l3 = l2[:]
	for j in range(n):
		l3[j] = (l3[j] + i) % l
	if sorted(l1) == sorted(l3):
		exit(print('YES'))
print('NO')


(n, l) = map(int, input().split())
first = [int(x) for x in input().split()]
second = [int(x) for x in input().split()]

def solve(n, l, first, second):
	ft = [0] * l
	st = [0] * l
	for i in range(n):
		ft[first[i] - 1] = 1
		st[second[i] - 1] = 1
	f = ''.join([str(x) for x in ft])
	f = f + f + f
	s = ''.join([str(x) for x in st])
	if s in f:
		return 'YES'
	return 'NO'
print(solve(n, l, first, second))