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: interview

Starter code:

Solutions:
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()

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

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 = 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")

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

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 = list(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 = list(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")


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


n, L = map(int, input().split())

if n == 1:
	print('YES')
	return

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")
		return

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


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 = list(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 = list(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")



q,w=list(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())
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')

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 = [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 = list(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 = 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")

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


k, n = list(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

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_r = sorted([(b + i) % L for b in B])
        if A == B_r:
            print('YES')
            break
    else:
        print('NO')

def __starting_point():
    solve()
__starting_point()