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
Tags: Mathematics

Implementation

Complete search
Skill types: Complete search

Starter code:

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())
tmp = list(map(int, input().split()))
answ = 'NO'
one = [0]
one.extend(tmp)
one.append(l)
tmp2 = list(map(int, input().split()))
two = [0]
two.extend(tmp2)
two.append(l)
kek = []
kek2 = []
for i in range(n + 1):
	tmp = one[i + 1] - one[i]
	kek.append(tmp)
for i in range(n + 1):
	tmp = two[i + 1] - two[i]
	kek2.append(tmp)
kek[0] += kek.pop()
kek2[0] += kek2.pop()
for i in range(n):
	if kek == kek2:
		answ = 'YES'
		break
	else:
		kek2.append(kek2.pop(0))
print(answ)


(n, m) = map(int, input().split())
c = list(map(int, input().split()))
d = list(map(int, input().split()))
a = []
b = []
for i in range(n - 1):
	a.append(c[i + 1] - c[i])
	b.append(d[i + 1] - d[i])
a.append(m - c[-1] + c[0])
b.append(m - d[-1] + d[0])
for i in range(n):
	if a == b:
		print('YES')
		break
	else:
		b.append(b.pop(0))
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')


(n, L) = map(int, input().split())
kefa = list(map(int, input().split()))
sasha = list(map(int, input().split()))

def check(kefa, sasha):
	X = [(kefa[i] - sasha[i] + L) % L for i in range(n)]
	if len(set(X)) == 1:
		return True
	else:
		return False

def rotate(arr, n):
	x = arr[n - 1]
	for i in range(n - 1, 0, -1):
		arr[i] = arr[i - 1]
	arr[0] = x
	return arr
ok = False
for l in range(n + 1):
	sasha = rotate(sasha, n)
	if check(kefa, sasha) == True:
		ok = True
if ok == True:
	print('Yes')
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())


inp = lambda : [*map(int, input().split())]
(n, m) = inp()
cal = lambda x: [m - x[-1] + x[0]] + [x[i] - x[i - 1] for i in range(1, n)]
a = cal(inp())
b = cal(inp())
for i in range(n):
	if a == b[i + 1:] + b[:i + 1]:
		print('YES')
		quit()
print('NO')


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] = [int(i) for i in str(input()).split(' ')]
r1 = [int(i) for i in str(input()).split(' ')]
r2 = [int(i) for i in str(input()).split(' ')]
for k in range(l):
	tmp = [(k + i) % l for i in r1]
	if all((i in r2 for i in tmp)):
		tmp = False
		break
if tmp == False:
	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(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 cyclic_equiv(a, b):
	u = [str(i) for i in a]
	v = [str(i) for i in b]
	t = ''.join(u)
	t += t
	if ''.join(v) in t:
		return True
	return False
(n, l) = input().split()
(n, l) = (int(n), int(l))
k = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
dk = [0 for i in range(n)]
ds = [0 for i in range(n)]
ldk = l - (k[n - 1] - k[0])
lds = l - (s[n - 1] - s[0])
for i in range(1, n):
	dk[i - 1] = k[i] - k[i - 1]
	ds[i - 1] = s[i] - s[i - 1]
dk[n - 1] = ldk
ds[n - 1] = lds
if cyclic_equiv(dk, ds):
	print('YES')
else:
	print('NO')


R = lambda : map(int, input().split())
(n, l) = R()
(a, b) = (list(R()), list(R()))
for i in range(l):
	for j in range(l):
		ans = 0
		for x in a:
			z = (i + x) % l
			if z >= j and z - j in b:
				ans += 1
			elif z < j and z - j + l in b:
				ans += 1
		if ans == n:
			print('YES')
			exit()
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())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
for i in range(l + 1):
	for j in range(n):
		l2[j] = l2[j] - 1
		if l2[j] < 0:
			l2[j] = l - 1
	l2.sort()
	if l2 == l1:
		print('YES')
		exit()
print('NO')


(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 ro(a):
	return a[1:] + [a[0]]
(n, l) = list(map(int, input().split()))
k = list(map(int, input().split()))
ks = []
s = list(map(int, input().split()))
ss = []
if n == 1:
	print('YES')
	exit()
for i in range(n - 1):
	ks.append(k[i + 1] - k[i])
	ss.append(s[i + 1] - s[i])
ks.append(l - k[i + 1] + k[0])
ss.append(l - s[i + 1] + s[0])
for i in range(n):
	ks = ro(ks)
	if ks == ss:
		print('YES')
		exit()
print('NO')


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')


(n, l) = map(int, input().split())
kefa = list(map(int, input().split()))
dasha = list(map(int, input().split()))
ke = kefa[0]
da = dasha[0]
for i in range(1, n):
	kefa[i - 1] = (kefa[i] - kefa[i - 1]) % l
	dasha[i - 1] = (dasha[i] - dasha[i - 1]) % l
dasha[-1] = (da - dasha[-1]) % l
kefa[-1] = (ke - kefa[-1]) % l
kefa_start = 0
dasha_start = 0
flag1 = 0
while dasha_start < n:
	if kefa[kefa_start] == dasha[dasha_start]:
		flag = 0
		for i in range(n):
			if kefa[kefa_start + i] != dasha[(dasha_start + i) % n]:
				flag = 1
				break
		if flag == 0:
			flag1 = 1
			break
	dasha_start += 1
if flag1 == 0:
	print('NO')
else:
	print('YES')


import sys
inp = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
f = 0
a = sorted(a)
for i in range(inp[1]):
	for j in range(inp[0]):
		b[j] = (b[j] + 1) % inp[1]
	if sorted(b) == a:
		print('YES')
		sys.exit()
print('NO')


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


(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')


def Main():
	result = False
	l1 = list(map(int, input().split()))
	obstacles = l1[0]
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	for i in reversed(range(0, obstacles)):
		A[i] = A[i] - A[0]
	for i in reversed(range(0, obstacles)):
		B[i] = B[i] - B[0]
	strA = ''.join((str(x) for x in A))
	strB = ''.join((str(x) for x in B))
	newStrB = strB + strB
	if strA in newStrB:
		result = True
	else:
		for i in range(1, obstacles):
			diff = B[i] - B[i - 1]
			for j in range(0, obstacles):
				A[j] = (A[j] + diff) % l1[1]
			strA = ''.join((str(x) for x in A))
			if strA in newStrB:
				result = True
				break
	if result == True:
		print('YES')
	else:
		print('NO')
Main()


(n, l) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = []
for t in range(1, n):
	d.append((b[t] - b[t - 1]) % l)
ok = 'NO'
for i in range(n):
	c = []
	for j in range(1, n):
		c.append((a[(i + j) % n] - a[(i + j - 1) % n]) % l)
	if c == d:
		ok = 'YES'
print(ok)


import sys
(n, L) = input().split()
n = int(n)
L = int(L)
k = [int(x) for x in input().split()]
s = [int(y) for y in input().split()]
a = []
b = []
for i in range(n - 1):
	a += [k[i + 1] - k[i]]
	b += [s[i + 1] - s[i]]
a += [k[0] + L - k[n - 1]]
b += [s[0] + L - s[n - 1]]
for i in range(n):
	if a == b:
		print('YES')
		sys.exit()
	c = a[0]
	a.pop(0)
	a.append(c)
print('NO')


(n, L) = map(int, input().split())
M = list(map(int, input().split()))
N = list(map(int, input().split()))
l = 0
for i in range(0, L):
	KK = []
	t = []
	for j in M:
		if j - i >= 0:
			KK.append(j - i)
		else:
			t.append(L + (j - i))
	KK = KK + t
	if KK == N:
		l = l + 1
		break
print('YES' if l != 0 else 'NO')


from sys import stdin

def computeDist(kefa):
	distance = [0] * post
	for i in range(post):
		distance[i] = kefa[i] - kefa[i - 1]
		if distance[i] < 0:
			distance[i] += length
	return distance

def rotate(i, distance):
	return distance[i:] + distance[:i]
(post, length) = map(int, stdin.readline().split())
kefa = list(map(int, stdin.readline().split()))
sasha = list(map(int, stdin.readline().split()))
distance1 = computeDist(kefa)
distance2 = computeDist(sasha)
for i in range(0, len(sasha)):
	if distance2[i] == distance1[0] and rotate(i, distance2) == distance1:
		print('YES')
		break
else:
	print('NO')


def R():
	return map(int, input().split())

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
(n, l) = R()
a = L()
b = L()
a = set(a)
b = set(b)
for i in range(l * 2):
	A = set([(x + i) % l for x in a])
	if A == b:
		print('YES')
		exit()
print('NO')


(n, L) = list(map(int, input().split()))
k = list(map(int, input().split()))
s = list(map(int, input().split()))
b = k[:]
while True:
	if k == s:
		print('YES')
		exit(0)
	if k[0] == 0:
		k = k[1:]
		k.append(L)
	for i in range(n):
		k[i] -= 1
	if k == b:
		print('NO')
		exit(0)


import sys
(N, L) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for shift in range(N):
	coincide = True
	diff = b[shift] - a[0]
	for i in range(1, N):
		if (a[i] + diff) % L != b[(i + shift) % N]:
			coincide = False
			break
	if coincide:
		print('YES')
		return
print('NO')


def track(tr):
	res = [l - tr[-1] + tr[0]]
	for i in range(1, n):
		res.append(tr[i] - tr[i - 1])
	return res

def equals(l1, l2):
	for i in range(n):
		res = True
		for k in range(n):
			res = res and l1[k] == l2[(k + i) % n]
		if res:
			return True
	return False
(n, l) = map(int, input().split())
a = track(list(map(int, input().split())))
b = track(list(map(int, input().split())))
if equals(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()))
for i in range(l):
	if a == b:
		print('YES')
		exit()
	for j in range(n):
		if a[j] == 0:
			a[j] = l - 1
		else:
			a[j] -= 1
	a = sorted(a)
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) = map(int, input().split())
l1 = list(map(int, input().split()))
l1.append(L + l1[0])
l2 = list(map(int, input().split()))
l2.append(L + l2[0])
d1 = []
d2 = []
for i in range(0, n):
	d1.append(l1[i + 1] - l1[i])
	d2.append(l2[i + 1] - l2[i])
ok = False
for i in range(0, n):
	d3 = d1[i:] + d1[0:i]
	if d3 == d2:
		ok = True
		break
if ok == True:
	print('YES')
else:
	print('NO')


(n, L) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a1 = []
b1 = []
a1.append(L + A[0] - A[-1])
for i in range(len(A) - 1):
	a1.append(A[i + 1] - A[i])
b1.append(L + B[0] - B[-1])
for i in range(len(B) - 1):
	b1.append(B[i + 1] - B[i])
ans = 'NO'
for i in range(L):
	b1 = b1[1:] + b1[0:1]
	if a1 == b1:
		ans = 'YES'
		break
print(ans)


(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')


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


(n, l) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = False
for i in range(l):
	c = sorted(list(map(lambda x: (x + i) % l, b)))
	if c == a:
		ans = True
print(('NO', 'YES')[ans])


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')


def same(kefa, sasha, length):
	i = 0
	svkefa = int(length) - int(kefa[-1]) + int(kefa[0])
	svsasha = int(length) - int(sasha[-1]) + int(sasha[0])
	while i < len(kefa) - 1:
		kefa[i] = int(kefa[i + 1]) - int(kefa[i])
		sasha[i] = int(sasha[i + 1]) - int(sasha[i])
		i += 1
	kefa[-1] = svkefa
	sasha[-1] = svsasha
	i = 0
	while i < len(kefa):
		e = 0
		array = sasha[i:] + sasha[:i]
		while True:
			if kefa[e] != array[e]:
				break
			e += 1
			if e == len(kefa):
				return True
		i += 1
	return False
i = input().split(' ')
print('YES' if same(list(map(int, input().split(' '))), list(map(int, input().split(' '))), i[1]) else 'NO')


import sys
(n, l) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
d = []
c.append(l - a[n - 1] + a[0])
d.append(l - b[n - 1] + b[0])
for i in range(1, n):
	c.append(a[i] - a[i - 1])
for j in range(1, n):
	d.append(b[j] - b[j - 1])
cnt = 0
p = 0

def match():
	count = 0
	for i in range(n):
		if c[i] == d[i]:
			count += 1
	if count < n:
		p = 0
	else:
		p = 1
	return p

def rotate():
	temp = d[n - 1]
	for j in range(n - 1, 0, -1):
		d[j] = d[j - 1]
	d[0] = temp
	return d
r = 0
m = 2
while r < n:
	r += 1
	m = match()
	if m == 0:
		rotate()
	else:
		break
if m == 0:
	print('No ')
elif m == 1:
	print('Yes')


(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')


import sys
import re
import math
import itertools
import collections
import bisect
mod = 1000000007
pi = 3.141592653589793
IS = float('inf')
xy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
bs = [(-1, -1), (-1, 1), (1, 1), (1, -1)]

def niten(a, b):
	return abs(a - b) if a >= 0 and b >= 0 else a + abs(b) if a >= 0 else abs(a) + b if b >= 0 else abs(abs(a) - abs(b))

def fib(n):
	return [(seq.append(seq[i - 2] + seq[i - 1]), seq[i - 2])[1] for seq in [[0, 1]] for i in range(2, n)]

def gcd(a, b):
	return a if b == 0 else gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

def eucl(x1, y1, x2, y2):
	return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

def choco(xa, ya, xb, yb, xc, yc, xd, yd):
	return 1 if abs((yb - ya) * (yd - yc) + (xb - xa) * (xd - xc)) < 1e-10 else 0

def pscl(num, l=[1]):
	for i in range(num):
		l = map(lambda x, y: x + y, [0] + l, l + [0])
	return l
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()]
x = deque()
y = deque()
for i in range(n):
	if i == 0:
		x.append(a[0] + (l - a[-1]))
	else:
		x.append(a[i] - a[i - 1])
for i in range(n):
	if i == 0:
		y.append(b[0] + (l - b[-1]))
	else:
		y.append(b[i] - b[i - 1])
for i in range(n):
	if x == y:
		print('YES')
		exit()
	tmp = x.popleft()
	x.append(tmp)
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')


from collections import deque
(i, j) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = []
for k in range(len(a)):
	if not k:
		A.append(a[k] + (j - a[-1]))
	else:
		A.append(a[k] - a[k - 1])
B = []
for k in range(len(b)):
	if not k:
		B.append(b[k] + (j - b[-1]))
	else:
		B.append(b[k] - b[k - 1])
B = deque(B)
S = False
for i in a:
	B.rotate(-1)
	if A == list(B):
		S = True
print('YES' if S 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):
	tmp = []
	for j in range(N):
		if a[j] < i:
			tmp.append(L - (i - a[j]))
		else:
			tmp.append(a[j] - i)
	mi = min(tmp)
	while tmp[0] != mi:
		tmp = tmp[1:] + [tmp[0]]
	if tmp == b:
		print('YES')
		exit()
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) = tuple(map(int, input().split()))
kefa = list(map(int, input().split()))
sasha = list(map(int, input().split()))
(diffsk, diffss) = ([], [])
for k in range(n):
	diffsk.append(kefa[k % n] - kefa[(k - 1) % n])
	diffss.append(sasha[k % n] - sasha[(k - 1) % n])
res = False
for j in range(n):
	tmp = True
	diff = (diffsk[0] - diffss[j]) % L
	for i in range(n):
		if (diffsk[i] - diffss[(i + j) % n]) % L != diff:
			tmp = False
	if tmp:
		res = True
if res:
	print('YES')
else:
	print('NO')


from collections import deque

def check(n, L, a, b):
	adiff = [a[i] - a[i - 1] for i in range(1, n)] + [L + a[0] - a[n - 1]]
	bdiff = [b[i] - b[i - 1] for i in range(1, n)] + [L + b[0] - b[n - 1]]
	adiff = deque(adiff)
	bdiff = deque(bdiff)
	for i in range(n):
		adiff.rotate()
		if adiff == bdiff:
			return 'YES'
	return 'NO'
(n, L) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(check(n, L, a, b))


import math

def main():
	a = input().split()
	x = int(a[0])
	y = int(a[1])
	found = False
	first = [int(x) for x in input().split()]
	second = [int(x) for x in input().split()]
	first_a = []
	second_a = []
	for i in range(len(first) - 1):
		if first[i + 1] - first[i] < 0:
			first_a.append(first[i + 1] - first[i] + y)
		else:
			first_a.append(first[i + 1] - first[i])
	if first[0] - first[-1]:
		first_a.append(first[0] - first[-1] + y)
	else:
		first_a.append(first[0] - first[-1])
	for i in range(len(second) - 1):
		if second[i + 1] - second[i] < 0:
			second_a.append(second[i + 1] - second[i] + y)
		else:
			second_a.append(second[i + 1] - second[i])
	if second[0] - second[-1]:
		second_a.append(second[0] - second[-1] + y)
	else:
		second_a.append(second[0] - second[-1])
	for i in range(x):
		second_a = second_a[1:len(second_a)] + [second_a[0]]
		if second_a == first_a:
			found = True
			break
	if found:
		print('YES')
	else:
		print('NO')
main()


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


(n, l) = list(map(int, input().split()))
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
flag = 0
for i in range(0, l):
	s3 = []
	for j in range(0, n):
		s3.append((s2[j] + i) % l)
	s3 = sorted(s3)
	if s1 == s3:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


(n, L) = map(int, input().split())
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
a0 = a[n - 1]
for i in range(n - 1, 0, -1):
	a[i] -= a[i - 1]
a[0] += L - a0
b0 = b[n - 1]
for i in range(n - 1, 0, -1):
	b[i] -= b[i - 1]
b[0] += L - b0
for i in range(L):
	flag = 0
	for j in range(n):
		if a[j] != b[(j + i) % n]:
			flag = 1
			break
	if flag == 0:
		break
if flag == 0:
	print('YES')
else:
	print('NO')


(n, L) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
da = []
db = []
for i in range(n - 1):
	da.append(abs(a[i] - a[i + 1]))
	db.append(abs(b[i] - b[i + 1]))
da.append(a[0] + L - a[-1])
db.append(b[0] + L - b[-1])
for i in range(n):
	if da == db:
		print('YES')
		quit()
	db = [db[-1]] + db[:-1]
print('NO')


(n, L) = [int(x) for x in input().strip().split()]
pos_kefa = [int(x) for x in input().strip().split()]
pos_sasha = [int(x) for x in input().strip().split()]
i = 0
found = False
while i < L:
	if pos_kefa != pos_sasha:
		pos_sasha = [x + 1 for x in pos_sasha]
		if pos_sasha[n - 1] == L:
			pos_sasha.pop()
			pos_sasha.insert(0, 0)
	else:
		print('YES')
		found = True
		break
	i += 1
if found is False:
	print('NO')


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


(n, L) = map(int, input().split())
(a, b) = (list(map(int, input().split())), list(map(int, input().split())))
(a_distances, b_distances) = ([], [])
for i in range(n - 1):
	a_distances.append(a[i + 1] - a[i])
	b_distances.append(b[i + 1] - b[i])
a_distances.append(a[0] + (L - a[-1]))
b_distances.append(b[0] + (L - b[-1]))
ans = False
for i in range(n):
	b_distances.append(b_distances.pop(0))
	if a_distances == b_distances:
		ans = True
		break
print('YES' if ans else 'NO')


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


f = lambda : map(int, input().split())
(n, l) = f()
a = list(f())
b = list(f())
ok = 0
for i in range(l):
	for j in range(n):
		if a == b:
			ok = 1
			print('YES')
			break
		t = b[0]
		for k in range(n - 1):
			b[k] = b[k + 1]
		b[n - 1] = t
	if ok:
		break
	b = list(map(lambda x: (x + 1) % l, b))
if not ok:
	print('NO')


def ri():
	return map(int, input().split())
(n, l) = ri()
a = list(ri())
b = list(ri())
ad = []
bd = []
for i in range(n - 1):
	ad.append(a[i + 1] - a[i])
	bd.append(b[i + 1] - b[i])
ad.append(l - a[n - 1] + a[0])
bd.append(l - b[n - 1] + b[0])
bd = bd + bd
for i in range(l):
	if ad == bd[i % n:(n + i) % n + n]:
		print('YES')
		exit()
print('NO')


import sys
(n, l) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
for i in range(l):
	for j in range(n):
		if a[j] != b[j]:
			break
	else:
		print('YES')
		sys.exit()
	for j in range(n):
		b[j] += 1
	for j in range(n):
		if b[j] >= l:
			b[j] -= l
	b.sort()
else:
	print('NO')


(n, L) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
ax = []
bx = []
x = a[0]
for i in a:
	ax.append(i - x)
	x = i
ax.append(L - x + a[0])
x = b[0]
for i in b:
	bx.append(i - x)
	x = i
bx.append(L - x + b[0])
st = 'NO'
ax.remove(ax[0])
bx.remove(bx[0])
while n > 0:
	n -= 1
	if ax == bx:
		st = 'YES'
	ax.append(ax[0])
	ax.remove(ax[0])
print(st)


def main():
	tmp = input()
	tmp = tmp.split(' ')
	n = int(tmp[0])
	l = int(tmp[1])
	tmp = input()
	tmp = tmp.split(' ')
	a = []
	for i in tmp:
		a.append(int(i))
	tmp = input()
	tmp = tmp.split(' ')
	b = []
	for i in tmp:
		b.append(int(i))
	a1 = []
	for i in range(1, len(a)):
		a1.append(a[i] - a[i - 1])
	a1.append(l - a[-1] + a[0])
	b1 = []
	for i in range(1, len(b)):
		b1.append(b[i] - b[i - 1])
	b1.append(l - b[-1] + b[0])
	tmp = len(a1)
	for i in range(tmp):
		lol = a1[0]
		a1.pop(0)
		a1.append(lol)
		if a1 == b1:
			print('YES')
			return 0
	print('NO')
main()


(n, l) = map(int, input().split())
r1 = list(map(int, input().split()))
r2 = list(map(int, input().split()))
r = []
s = []
for i in range(n - 1):
	r.append(r1[i + 1] - r1[i])
r.append(l - r1[n - 1] + r1[0])
for i in range(n - 1):
	s.append(r2[i + 1] - r2[i])
s.append(l - r2[n - 1] + r2[0])
for i in range(n + 1):
	l1 = list(s[i:] + s[:i])
	if l1 == r:
		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) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a[0] > b[0]:
	(a, b) = (b, a)
dist = 0
for i in range(n):
	dist = a[0] - b[i]
	for j in range(n):
		c = b[(i + j) % n]
		if i + j >= n:
			c += l
		if dist != a[j % n] - c:
			break
	else:
		print('YES')
		exit()
print('NO')


(n, L) = map(int, input().split())
k = list(map(int, input().split()))
s = list(map(int, input().split()))
for i in range(L):
	s = sorted(((si + 1) % L for si in s))
	if s == k:
		print('YES')
		exit()
print('NO')


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


def cyclic_equiv(u, v):
	(n, i, j) = (len(u), 0, 0)
	if n != len(v):
		return False
	while i < n and j < n:
		k = 1
		while k <= n and u[(i + k) % n] == v[(j + k) % n]:
			k += 1
		if k > n:
			return True
		if u[(i + k) % n] > v[(j + k) % n]:
			i += k
		else:
			j += k
	return False
(n, l) = input().split()
(n, l) = (int(n), int(l))
k = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
dk = [0 for i in range(n)]
ds = [0 for i in range(n)]
ldk = l - (k[n - 1] - k[0])
lds = l - (s[n - 1] - s[0])
for i in range(1, n):
	dk[i - 1] = k[i] - k[i - 1]
	ds[i - 1] = s[i] - s[i - 1]
dk[n - 1] = ldk
ds[n - 1] = lds
if cyclic_equiv(dk, ds):
	print('YES')
else:
	print('NO')


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


from collections import deque
(n, l) = map(int, input().split())
a1 = [0] * l
b1 = [0] * l
a = map(int, input().split())
b = map(int, input().split())
for i in a:
	a1[i] = 1
for i in b:
	b1[i] = 1
a = deque(a1)
b = deque(b1)
c = 0
for i in range(l):
	a.rotate()
	if a == b:
		c = 1
		break
print('YES') if c == 1 else print('NO')


(n, L) = map(int, input().split())
(kefa, sasha) = (list(), list())
for i in input().split():
	kefa.append(int(i))
for i in input().split():
	sasha.append(int(i))
k = list()
s = list()
klen = L
slen = L
for i in range(n - 1):
	k.append(kefa[i + 1] - kefa[i])
	klen -= k[-1]
	s.append(sasha[i + 1] - sasha[i])
	slen -= s[-1]
k.append(klen)
s.append(slen)

def jud(k, s, n):
	for i in range(n):
		if k == s:
			return 'YES'
		k = k[1:] + k[0:1]
	return 'NO'
print(jud(k, s, n))


(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) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
(x, y) = ([], [])
for i in range(n):
	if i == 0:
		x.append(a[i] + (l - a[-1]))
	else:
		x.append(a[i] - a[i - 1])
for i in range(n):
	if i == 0:
		y.append(b[i] + (l - b[-1]))
	else:
		y.append(b[i] - b[i - 1])
y = y + y
for i in range(n):
	f = 1
	for j in range(n):
		if x[j] != y[j + i]:
			f = 0
	if f:
		print('YES')
		exit()
print('NO')


inp = input().split()
n = int(inp[0])
l = int(inp[1])
inp = input().split()
a = [int(i) for i in inp]
inp = input().split()
b = [int(i) for i in inp]
ans = 'NO'
flag = 0
for i in range(l):
	flag = 0
	for r in a:
		if (r + i) % l not in b:
			flag = 1
			break
	if not flag:
		ans = 'YES'
		break
print(ans)


(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')


(n, l) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ans = False
for bega in range(n):
	for begb in range(n):
		ch = True
		for i in range(n):
			(x, y) = (0, 0)
			if bega + i + 1 == n:
				x = l - a[n - 1] + a[0]
			else:
				x = a[(bega + i + 1) % n] - a[(bega + i) % n]
			if begb + i + 1 == n:
				y = l - b[n - 1] + b[0]
			else:
				y = b[(begb + i + 1) % n] - b[(begb + i) % n]
			if x != y:
				ch = False
				break
		if ch:
			ans = True
			break
	if ans:
		break
if ans:
	print('YES')
else:
	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))