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.    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.

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.

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

NoteThe first test is analyzed in the statement.

#include <iostream>
#include <vector>
using namespace std;

int n, L;
vector<int> a, b, tmp;

bool check()
{
	int p = a[0] - tmp[0];

	for (int i = 1; i < n; i++)
		if (a[i] - tmp[i] != p)
			return false;

	return true;
}

int main()
{
	cin >> n >> L;
	a.resize(n), b.resize(n), tmp.resize(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int j = 0; j < n; j++)
		cin >> b[j];

	for (int i = 0; i < n; i++) {
		int count = 0;
		for (int j = i; j < n; j++)
			tmp[count++] = b[j];
		for (int j = 0; j < i; j++)
			tmp[count++] = b[j] + L;
		if (check() == true) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lld long long int
#define ll long double
#define p(x) cout<<x<<endl
#define vect(x,n) vector<lld>x(n,0)
#define sorta(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.begin(),v.end(),greater<lld>())
#define all(v) v.begin(),v.end()
#define matrix(x,n,m) vector<vector<lld>>x(n,vector<lld>(m,0))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define lb lower_bound
#define F first
#define S second
#define pb push_back
#define mkp make_pair
const lld mod=1e9+7;
lld pow(lld x, lld y) { lld res = 1; while (y >(lld)0) { if (y &(lld)1) res = ((res) * (x)); y = y >>(lld)1; x = ((x) * (x)); } return res; }

void solve()
{
    lld i,j,k,ans,a,b,c,mx,mn,t,n,m,x,temp,p,q,y,z,l,r,g,flg,sum,d,cnt,sumf,diff,odd,even;
    cin>>n>>a;
    vector<lld>arr1(n),arr2(n),sasha,kefa;
    for(i=0;i<n;i++)
        cin>>arr1[i];
    for(i=0;i<n;i++)
        cin>>arr2[i];

    for(i=1;i<n;i++)
        sasha.pb(arr1[i]-arr1[i-1]);
    sasha.pb(arr1[0]+a-arr1[n-1]);
    for(i=1;i<n;i++)
        kefa.pb(arr2[i]-arr2[i-1]);
    kefa.pb(arr2[0]+a-arr2[n-1]);

    for(i=0;i<n;i++)
        sasha.pb(sasha[i]);

    for(i=0;i<n;i++)
    {
        flg=0;
        for(j=0;j<n;j++)
        {
            if(sasha[i+j]!=kefa[j])
            {
                flg=1;
                break;
            }
        }
        if(flg==0)
            break;
    }
    if(flg==0)
        p("YES");
    else
        p("NO");
    return;
}

int main()
{
    fast;
    lld t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

#include<bits/stdc++.h>
#include<vector>
#include<unordered_map>
#include<iostream>
#include<string>
#include<deque>
#include<algorithm>
using namespace std;
void ok()
{
     ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ok();
	long n,l,suma=0,sumb=0;
	vector<long >a1,b1;
	cin>>n>>l;

	long a[n],b[n];

	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n;i++)
	cin>>b[i];

	for(int i=0;i<n;i++)
	{
        if(i+1<n)
        {

            a1.push_back(abs(a[i+1]-a[i]));
            b1.push_back(abs(b[i+1]-b[i]));
            //suma+=abs(a[i+1]-a[i]);
            //sumb+=abs(b[i+1]-b[i]);
        }
	}
	//cout<<suma+a[0];
	//if(suma+a[0]>l||sumb+b[0]>l)
	//{cout<<"NO";return 0;}
	a1.push_back(a[0]+(l-a[n-1]));
    b1.push_back(b[0]+(l-b[n-1]));

    bool t1=1;
    long ss=a1.size();
    for(int i=0;i<ss;i++)
    {
        t1=1;
        long j=i,j2=0;
        do
        {
            if(a1[j2]!=b1[j])
            {t1=0;    break;}
            j++;
            j2++;
            j2%=ss;
            j%=ss;
        }while(j!=i);
        if(t1)
        {cout<<"YES";   return 0;}
    }
    cout<<"NO";
}

#include <iostream>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n,L;
    cin>>n>>L;
    int v1[n];
    int v2[n];
    for(int i=0;i<n;i++)
    {
        cin>>v1[i];
    }
     for(int i=0;i<n;i++)
    {
        cin>>v2[i];
    }
      vector<int> vv,vv2;
    for(int i=0;i<n-1;i++)
    {
        vv.push_back(abs(v1[i]-v1[i+1]));
     //   cout<<vv[i];
    }
    vv.push_back(L-v1[n-1]+v1[0]);
     for(int i=0;i<n-1;i++)
    {
        vv2.push_back(abs(v2[i]-v2[i+1]));
    }
    vv2.push_back(L-v2[n-1]+v2[0]);

    int fl=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(vv[j]!=vv2[j])
                break;
            if(j==n-1)
            {
                fl=1;
                cout<<"YES";
                break;
            }
        }
        if(fl==1)break;

            int c=vv2[vv2.size()-1];
            vv2.pop_back();
            vector<int>::iterator it;
            it = vv2.begin();
            vv2.insert ( it , c );

    }
     if(fl==0)
         cout<<"NO";

    return 0;
}

#include<bits/stdc++.h>

#define fast                     ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int                      long long
#define pb                       push_back
#define pii                      pair<int,int>
#define vi                       vector<int>
#define vii                      vector<pii>
#define mi                       map<int,int>
#define mii                      map<pii,int>
#define all(a)                   (a).begin(),(a).end()
#define F                        first
#define S                        second
#define sz(x)                    (int)x.size()
#define endl                     '\n'
#define MOD                      1000000007
#define loop(i,a,b)              for(int (i)=(a);(i)<(b);(i)++)
#define rloop(i,a,b)             for(int (i)=(a);(i)>=(b);(i)--)
#define Unique(A)                (A).resize(distance((A).begin(),unique(all((A)))))
#define MXe(A)                   *max_element(all(A))
#define MNe(A)                   *min_element(all(A))
#define SP(val,precision)        fixed << setprecision((precision)) << (val)
#define setBits(x)               __builtin_popcountll(x)
#define zroBits(x)               __builtin_ctzll(x)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define mem(name,val)            memset(name,val,sizeof(name))
#define traceA(A,x)              cerr<<#A<<": ";loop(i,0,x)cerr<<A[i]<<' ';cerr<<endl
#define traceV(A)                cerr<<#A<<": ";for(auto i:A)cerr<<i<<' ';cerr<<endl
#define maxheap                  priority_queue<int>
#define minheap                  priority_queue<int,vector<int>,greater<int>>

using namespace std;

const int N = 2e5+77;
int A[N] , B[N];

int32_t main(){
    int n , l ; cin >> n >> l ;
    loop(i,0,n) cin >> A[i];
    loop(i,0,n) cin >> B[i];
    vi Ans1 ,Ans2;
    loop(i,0,n){
        if(i==n-1){
            int d = l-A[i] + A[0];
            int x = l-B[i] + B[0];
            Ans1.pb(d);
            Ans2.pb(x);
        }
        else {
            int d = A[i+1] - A[i];
            int x = B[i+1] - B[i];
            Ans1.pb(d);
            Ans2.pb(x);
        }
    }
    while(n--){
        if(Ans1==Ans2){
            cout << "YES" << endl;
            return 0;
        }
        rotate(Ans1.begin(),Ans1.begin()+1,Ans1.end());
    }
    cout << "NO" << endl;
    return 0;
}

#include        <bits/stdc++.h>

using           namespace       std;

#define         trace1(x)       cout << #x << " = " << x << '\n';
#define         trace2(x,y)     cout << #x << " = " << x << " | " << #y << " = " << y << '\n';
#define         trace3(x,y,z)   cout << #x << " = " << x << " | " << #y << " = " << y << " | " << #z << " = " << z << '\n';

typedef         long long       ll;
typedef         vector<int>     vi;
typedef         pair<int, int>  pi;
typedef         map<int, int>   mp;

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;
const long long inf = 1e18 + 1;
const long double eps = pow(2, -52);

int main()
{
        int n, l, a[150], b[150];
        cin >> n >> l;
        for(int i = 0; i < n; i++)
                cin >> a[i];
        for(int i = 0; i < n; i++)
                cin >> b[i];
        if(n == 1)
        {
                cout << "YES";
                return 0;
        }
        int x = l - a[n-1] + a[0];
        int y = l - b[n-1] + b[0];
        vi xx, yy;
        for(int i = 1; i < n; i++)
                xx.push_back(a[i] - a[i-1]);
        for(int i = 1; i < n; i++)
                yy.push_back(b[i] - b[i-1]);
        xx.push_back(x);
        yy.push_back(y);

        int sz = xx.size();
        vi one, two;

        for(int i = 0; i < sz; i++)
        {
                for(int j = 0; j < sz; j++)
                {
                        one.clear();
                        two.clear();
                        int k = i;
                        int cnt = 0;
                        while(cnt < sz)
                        {
                                k %= sz;
                                one.push_back(xx[k]);
                                cnt++;
                                k++;
                        }
                        k = j;
                        cnt = 0;
                        while(cnt < sz)
                        {
                                k %= sz;
                                two.push_back(yy[k]);
                                cnt++;
                                k++;
                        }
                        int lol = 1;
                        for(int in = 0; in < one.size(); in++)
                        {
                                if(one[in] != two[in])
                                        lol = 0;
                        }
                        if(lol)
                        {
                                cout << "YES";
                                return 0;
                        }

                }
        }
        cout << "NO";
        return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double eps = 1e-6;
const int INF = 2e9;
const LL LNF = 9e18;
const int mod = 1e9+7;
const int maxn = 100+10;

int n,L;
int a[maxn], b[maxn];
int c[maxn], d[maxn];

int main()
{
    cin>>n>>L;
    for(int i = 1; i<=n; i++)
        cin>>a[i];
    for(int i = 1; i<=n; i++)
        cin>>b[i];

    a[n+1] = L+a[1], b[n+1] = L+b[1];
    for(int i = 1; i<=n; i++)
    {
        c[i] = a[i+1]-a[i];
        d[i] = b[i+1]-b[i];
    }

    int B = 0;
    for(int i = 0; i<n; i++)
    {
        int t;
        for(t = 1; t<=n; t++)
        {
            int j = (i+t)<=n?(i+t):(i+t)%n;
            if(c[t]!=d[j])
                break;
        }
        if(t==1+n)
        {
            B = 1;
            break;
        }
    }

    if(B)
        puts("YES");
    else
        puts("NO");
}

/* ********************************************* */
/*     Codeforces round 394                      */
/*     Bulbasaur Sabo                            */
/*     Kazakh-British TU 5, Team Sorry           */
/*	   Problem B                                 */
/* ********************************************* */
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 100;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
const double pi = acos(-1);

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <pii> vpi;
typedef vector <pll> vpl;

#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) int(a.size())
#define pb push_back
#define mp make_pair
#define file "A"

// close your eyes and belive that this work

int n, a[1010], b[1010], l;

int main(){
   	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	 cin >> n >> l;
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    for(int i=0;i<n;i++) {
    	bool ok = true;
    	int p = (a[0] + l - b[0+i]) % l;
    	for(int j=1;j<n;j++) {
    		if((a[j] + l - b[(j+i)%n]) % l != p) {
    			ok = false;
    			break;
    		}
    	}
    	if(ok) {
    		cout << "YES" << endl;
    		return 0;
    	}
    }
    cout << "NO" << endl;
	#ifndef ONLINE_JUDGE
        fprintf(stderr, "Time: %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ll long long
#define ss second
#define pb push_back
#define pf push_front
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp make_pair

int main()
{
    IOS;
    ll a,b;
    cin>>a>>b;
    vector<int> d(a);
    vector<int> s(a);
    for(int i=0;i<a;i++)
    cin>>d[i];
    for(int i=0;i<a;i++)
    cin>>s[i];
    if(a==1)
    {
        cout<<"YES";
        return 0;
    }
    vector<int> v1(a);
    vector<int> v2(a);
    int m1=100000;
    int m2=1000000;
    int pos1,pos2;
    int n=a;
    for(int i=1;i<a;i++)
    {
        v1[i-1]=d[i]-d[i-1];
        if(v1[i-1]<m1)
        {
            m1=v1[i-1];
            pos1=i-1;
        }

        v2[i-1]=s[i]-s[i-1];
        if(v2[i-1]<m2)
        {
            m2=v2[i-1];
            pos2=i-1;
        }
    }
    v1[a-1]=b-d[a-1]+d[0];
   v2[a-1]=b-s[a-1]+s[0];
   bool ch=0;
  for(int i=0;i<n;i++)
  {
      bool check=true;
      int ptr=0;
      for(int j=i;j<n;j++)
      {
          if(v1[ptr]==v2[j])
          ;
          else
          check=false;
          ptr++;
      }
      if(check)
      {
          for(int j=0;j<i;j++)
          {
               if(v1[ptr]==v2[j])
          ;
          else
          check=false;
          ptr++;
          }
      }
      ch|=check;
  }
  if(ch)
  cout<<"YES";
  else
    cout<<"NO";
    return 0;
}

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

int n, l;
int k[55], s[55];
int cpk[55], cps[55];
int cnt;
int main()
{
	bool flag;
	while(scanf("%d %d", &n, &l) != EOF)
	{
		flag = 0;
		for(int i = 1; i <= n; i++) scanf("%d", &k[i]);
		for(int i = 1; i <= n; i++) scanf("%d", &s[i]);
		for(int i = 1; i <= l; i++)
		{
			cnt = 0;
			for(int j = 1; j <= n; j++)
				cpk[j] = (k[j] + i) % l;
			sort(cpk + 1, cpk + n + 1);
			for(int j = 1; j <= n; j++)
				if(cpk[j] == s[j])
					cnt++;
			if(cnt == n)
			{
				flag = 1;
				break;
			}
		}
		if(flag) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;

long long n, L;
long long a[100], b[100];

void main() {
	long long testCases;
	//freopen("input.txt", "r", stdin);

	cin >> n >> L;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	for (int i = 0; i < n; i++)
		cin >> b[i];

	int sumA = 0, sumB = 0;

	for (int i = n - 1; i >= 1; i--) b[i] -= b[i - 1], sumB += b[i];
	for (int i = n - 1; i >= 1; i--) a[i] -= a[i - 1], sumA += a[i];

	b[0] = L - sumB;
	a[0] = L - sumA;

	bool ans;

	for (int i = 0; i < n; i++) {
		ans = true;
		for (int j = 0; j < n; j++)
			if (a[(i + j) % n] != b[j]) {
				ans = false;
				break;
			}
		if (ans) {
			cout << "YES";
			return;
		}
	}

	cout << "NO";
}

#include<iostream>
#include <stdio.h>
#include <stdlib.h>

int main(){
    int n,l,i,j,x=1,y=0,z;
    scanf("%d %d",&n,&l);
    int a[n],b[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
        scanf("%d",&b[i]);

    int c=a[0],d=b[0];
    for(i=0;i<n-1;i++){
        a[i]=a[i+1]-a[i];
        b[i]=b[i+1]-b[i];
    }
    a[n-1]=l-a[n-1]+c;
    b[n-1]=l-b[n-1]+d;

    int f=0;
	for(d=0;d<n;d++)
	{
	    for(i=0;i<n;i++)
	    if(a[i]!=b[(i+d)%n])
	    break;

	    if(i==n){
            f=1;break;}
	}
	if(f==1)
        printf("YES\n");
	else
        printf("NO\n");
    return 0;
}

                                      ///  ***  In The Name of God ... ***  ///
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bug() cout << "BUG" << endl ;
#define X first
#define Y second
#define Size(x) (int)x.size()
typedef long long ll;
const ll INF = 1e18 ;

const ll MAXN = 50 + 20 ;
ll n , l , a[MAXN] , b[MAXN] , A[MAXN] , B[MAXN] ;

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> l ;
	for(ll i = 0 ; i < n ; i++)
		cin >> a[i] ;
	for(ll j = 0 ; j < n ; j++)
		cin >> b[j] ;
	for(ll i = 1 ; i < n ; i++)
		A[i - 1] = a[i] - a[i - 1] ;
	for(ll i = 1 ; i < n ; i++)
		B[i - 1] = b[i] - b[i - 1] ;
	A[n - 1] = l - a[n - 1] + a[0] ;
	B[n - 1] = l - b[n - 1] + b[0] ;
	for(ll i = 0 ; i < n ; i++)
	{
		bool isAns = false ;
		if(A[i] == B[0])
		{
			ll cnt = 0 ;
			for(ll j = i ; j < n ; j++)
			{
				if(A[j] == B[cnt])
					cnt++ ;
				else
					isAns = true ;
			}
			for(ll j = 0 ; j < i ; j++)
			{
				if(A[j] == B[cnt])
					cnt++ ;
				else
					isAns = true ;
			}
			if(!isAns)
				return cout << "YES" , 0 ;
		}
	}
	cout << "NO" ;

}

#include<cstdio>
#include<cstring>
#include<queue>
#include<set>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
int a[110],b[110];
int t1[110],t2[110];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=2;i<=n;i++)
		t1[i]=a[i]-a[i-1];
	t1[1]=a[1]+m-a[n];
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=2;i<=n;i++)
		t2[i]=b[i]-b[i-1];
	t2[1]=b[1]+m-b[n];
	int flag=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(t1[i]==t2[j])
			{
				int num=0;
				for(int s1=i,s2=j;num<n;num++)
				{
					if(t1[s1]!=t2[s2])
						break;
					s1++;s2++;
					if(s1==n+1)
						s1=1;
					if(s2==n+1)
						s2=1;
				}
				if(num==n)
				{
					flag=1;
					break;
				}
			}
		}
		if(flag==1)
			break;
	}
	if(flag)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}

#include<bits/stdc++.h>
#define MAX 1000007
#define MIN -1000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long int ll;
typedef long double ld;

int main()
{ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 ll n,m,i,j,l;
 cin>>n>>l;
 ll a[n],b[n];
 for(i=0;i<n;i++)
 	cin>>a[i];

for(i=0;i<n;i++)
	cin>>b[i];
	//cout<<"\n";
for(i=0;i<l;i++)
{ ll ctr=0;
	for(j=0;j<n;j++)
	{ ctr=0;
		for(ll k=0;k<n;k++)
		{
			if(a[(j+k)%n]==b[k])
				ctr++;
				//cout<<a[(j+k)%n]<<" ";

		}
		if(ctr==n)
		{
			cout<<"YES\n";
			return 0;
		}
		//cout<<"\n";

	}
    //cout<<"\n";
	for(j=0;j<n;j++)
	{
		if(a[j]>0)
		a[j]--;
		else
		a[j]=l-1;
	}

}
cout<<"NO";
return 0;
}

//Pratyush Prakash

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <set>

#include <map>
#include <queue>
#include <list>
#include <math.h>

#define ll long long int
#define maxN 200
#define maxVal 1e8
#define minVal -1e8
#define mod 1e9+7
#define mp make_pair
#define pb push_back
#define gcd(a,b) __gcd(a,b)

using namespace std;
int a[105],b[105],c[105],n,l;
bool check(int in)
{
    int d,i,j;
    d = a[0]-b[in];
    for(i=0;i<n;i++)
    {
        c[i]=b[i]+d;
        if(c[i]<0)
            c[i]+=l;
       // cout << c[i] << " ";
    }
    //cout << endl;
    for(i=0;i<n;i++)
        {
            if(a[i]!=c[in%n])
                return false;
            in=(in+1)%n;
        }
    return true;
}
int main()
{
    int i,j,k,f=-1;
    ios::sync_with_stdio(false);
    cin >> n >> l;
    for(i=0;i<n;i++)
        cin >>a[i];
    for(i=0;i<n;i++)
        cin >> b[i];
    for(i=0;i<n;i++)
    {
        if(check(i)==true)
        {
            f=0;
            break;
        }
    }
    if(f==0)
        cout <<"YES"<<endl;
    else
        cout << "NO" << endl;
}

/*****************************************************************\
IN THE NAME OF ALLAH, MOST GRACIOUS AND MOST MERCIFUL
|                                                                 |
|     Author     : Mahabub Rahman                                 |
|     Email      : mahabubrahman618@gmail.com                     |
|     University : Comilla University, Bangladesh                 |
|                  Department of Computer Science & Engineering   |
\*****************************************************************/

/*...................................Data_Types............................................*/
#include<bits/stdc++.h>

using namespace std;
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define       ll                  long long int
#define       ull                  unsigned long long int
#define       veci                 vector<int>
#define       vecc                 vector<char>
#define       vecs                 vector<string>
#define       vecl                 vector<long long int>
#define       vecp                 vector<  pair<int,int> >
#define       mapstrint            map< string , int >
#define       mapstrstr            map< string , string >
#define       mapint               map< int, int >
#define       pb                   push_back
#define       newline cerr << endl
#define       pob                  pop_back
#define       mp                   make_pair
#define       pii                  pair<int, int>
#define       F                    first
#define       S                    second
#define       sc(x)                scanf("%d",&x)
#define       sc2(xx,zz)           scanf("%d %d",&xx,&zz)
#define       scl(x)               scanf("%lld",&x)
#define       scl2(xx,zz)          scanf("%lld %lld",&xx,&zz)
#define       pf                   printf
#define       min3(a,b,c)          min(a,b<c?b:c)
#define       max3(a,b,c)          max(a,b>c?b:c)
#define       all(v)               v.begin(), v.end()
///=============== Debugging ============================///
#define       debug(x) cerr << #x << " = " << x << endl
#define       debug2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define       debug3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define       debug4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
//#define f(x) (64 - __builtin_clzll(x))
///============ CONSTANT ===============///
#define mx9   1000000007
#define mx7   10000007
#define mx6   2000006
#define mx5   200005
#define inf   1<<30                                           //infinity value
#define eps   1e-9
#define mod   mx9
///==============================TEMPLATES===============================///

long double PI = acosl(-1);
bool compare_int(int a, int b){return (a>b);} //This function is use for descending order.
bool compare_string (string a, string b){return a.size()<b.size();}
bool compare_pair(const pair<int,int> &a,
                    const pair<int,int> &b){if(a.second==b.second)return a.first<b.first; else return (a.second > b.second);}
bool cmp(pair<string ,int > x , pair<string ,int > y){return (x.S < y.S);}
///=====================Graph Moves================///
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move

///=====================Bitmask===================///
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}

///========================================FUNCTION=========================================///
//bool check(int n){if(n==1) return false; for(int i=2; i*i<=n; i++){if(n%i==0) return false;} return true;}
//ll bigmod(ll a, ll b, ll m){if(b==0) return 1%m;ll x=bigmod(a, b/2, m);x=(x*x)%m;if(b%2==1)x=(x*a)%m;return x;}
//bool flag[mx5];veci prime;
//void sieve(){prime.pb(2);for(ll i=3; i*i<=mx5; i+=2){if(flag[i]) continue;for(ll j=i*i; j<=mx5; j+=i+i) flag[j]=true;}for(ll i=3; i<=mx5; i+=2) if(!flag[i]) prime.pb(i);}
//ll fact(ll n){if(n==0 or n==1)return 1; else return n*fact(n-1);}
void NA(){printf("NO\n");exit(0);}
void YA(){printf("YES\n");exit(0);}

///=================START_FROM_HERE=====================///

int32_t main()
{
    ///Don't see test case until get 7/8 times wrong submission..!!
    ///Try to make Corner, Even, Odd or Prime case..!!
    FastIO;
    int n, m, x;
    cin >> n >> m;
    int a[n+1], b[n+1];
    veci da, db;

    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        if(i>0)
        {
            x = a[i]-a[i-1];
            da.pb(x);
        }
    }
    x = a[0]+m-a[n-1];
    da.pb(x);
    for(int i=0; i<n; i++)
    {
        cin >> b[i];
        if(i>0)
        {
            x = b[i]-b[i-1];
            db.pb(x);
        }
    }
    x = b[0]+m-b[n-1];
    db.pb(x);
    for(int i=0; i<n; i++) db.pb(db[i]);
    //for(int i=0; i<db.size(); i++) cout << db[i] << ' ';
    //cout << endl;
    bool ok = false;
    for(int i=0; i<=n; i++)
    {
        int cnt=0;
        for(int j=0; j<n; j++)
        {
            if(da[j]!=db[i+j]) break;
            else cnt++;
        }
        if(cnt==n)
        {
            ok = true;
            break;
        }
    }
    if(ok) YA();
    else NA();
}
///Created:

/*
     riirr                                                        rLir                         BBBr
    rBBBBB                                                        tBBP                         PBMr
    aBBbBBZ        rLtstT      Tltstr     rslsi     rLir YsTr    rkBBDLss    rTsLsr       rLlLihBbr
   rBBy UBBr     tBBBBBBBD  rHBBBBBBBr  CBBHHDBBh   FBBBBBBBBBL  mBBBBBBBr  hBbhHBBBC   iBBBBBBMBDr
   DBh   bBD    XBBm     r rBBBi    r  ZBBtrriHBBa  YBBs   rbBBr  rBMy     BBMrrrtBBBr vBBHr   mBbr
  UBBBBBBBBBF   MBB        vBBa        BBBDHBMDmHi  YBBv    EBBr  TBBy    lBBMDbBbHPE  yBBT    EBDr
 rBBPTvliyBBBr  XBBS     r rBBMr    r  hBBr         iBBL   iBBBr  yBBa    rBBb         tBBa    kBMr
rBBBr     CBBBr  tBBBBBBBD  rDBBBBBBBr  yBBBBBBBBt  YBBbBBBBBkr   rBBBBBBr rhBBBBBBBBr  ZBBBBBMBBBr
rsTr       rYsr    rsytyL      Tsytyr     rstttyr   vBByrTlLr       rTsSs     Ytttts      vssv rvi
                                                    CBBC
                                                     rr                                             */
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <stack>
#include <cstring>
#include <cmath>
#include <vector>
#include <ctime>
#include <ostream>
using namespace std;
typedef long long ll;
#define pb push_back
#define scand(n) scanf("%d",&n)
#define scandd(n,m) scanf("%d%d",&n,&m)
#define scanlld(n) scanf("%lld",&n)
#define scanlldd(n,m) scanf("%lld%lld",&n,&m)
#define scans(str) scanf("%s",str)
#define ans() printf("%d",ans)
#define ansn() printf("%d\n",ans)
#define anss() printf("%d ",ans)
#define llans() printf("%lld",ans)
#define llanss() printf("%lld ",ans)
#define llansn() printf("%lld\n",ans)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REE(i,qwe,ewr) for(int i=qwe;i<=ewr;++i)
#define mst(abc,bca) memset(abc,bca,sizeof abc)
const int mod = 1000000007;
const int N=500000+10;
int a[100],b[100];
int main()
{
#ifdef LOCAL
    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif // LOCAL
    int n,m;
    vector<int>aa,bb;
    scandd(n,m);
    REP(i,n)scand(a[i]);
    REP(i,n)scand(b[i]);
    bool ok=0;
    for(int i=0; i<n; ++i)
    {
        if(i==0)aa.pb((a[i]+m-a[n-1])%m);
        else aa.pb(a[i]-a[i-1]);
    }
    for(int i=0; i<n; ++i)
    {
        if(i==0)bb.pb((b[0]+m-b[n-1])%m);
        else {
            bb.pb(b[i]-b[i-1]);
//            printf("%d",b[i]-b[i-1]);
        }
    }
//    REP(i,bb.size())printf("%d ",bb[i]);
    for(int i=0;i<n;++i)
    {
        if(aa==bb){
            ok=1;
            break;
        }
        else {
            int tmp=bb[0];
            bb.erase(bb.begin());
            bb.pb(tmp);
        }
    }
    if(ok)printf("YES");
    else printf("NO");
    return 0;
}

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
  int A1[55],A2[55],B1[55],B2[55];
  int i,n,l;
  cin>>n;
  cin>>l;
  for(i=0;i<n;i++)
  {
    cin>>A1[i];
  }
  for(i=0;i<n;i++)
  {
    cin>>A2[i];
  }
  for(i=0;i<n-1;i++)
  {
    B1[i] = A1[i+1]-A1[i];
    B2[i] = A2[i+1]-A2[i];
  }
  B1[n-1] = l-A1[n-1]+A1[0];
  B2[n-1] = l-A2[n-1]+A2[0];
  for(i=0;i<n;i++)
  {
    int pos1 = i;
    int pos2 = 0;
    int count = 0;
    int flag = 1;
    while (count < n)
    {
      if(B1[pos1]!=B2[pos2])
      {
        flag = 0;
        break;
      }
      pos1 = (pos1+1)%n;
      pos2++;
      count++;
    }
    if(flag)
    {
      cout<<"YES";
      return 0;
    }
  }
  cout<<"NO";
  return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <queue>
#include <cmath>
#include <cctype>
using namespace std;

typedef long long ll;

int main()
{
#ifdef _KOCHERGIN
	freopen("abc.txt", "r", stdin);
#else
	//freopen("sweets.in", "r", stdin);
	//freopen("sweets.out", "w", stdout);
#endif
	int n, l;
	cin >> n >> l;
	vector <int> v(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i];
	}
	vector <int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < l; ++i)
	{
		bool f = false;
		int k = n;
		for (int j = 0; j < n; ++j)
		{
			if (v[j] >= i)
			{
				k = j;
				break;
			}
		}
		for (int j = 0; j < n-k; ++j)
		{
			if (a[j] != v[j+k] - i)
			{
				f = true;
				break;
			}
		}
		for (int j = 0; j < k; ++j)
		{
			if (a[j + n - k] != l - i + v[j])
			{
				f = true;
				break;
			}
		}
		if (!f)
		{
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

#include <bits/stdc++.h>

#define maxn 100000008
#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main(int argc, char *argv[])
{
	int n, l;
	scanf("%d %d", &n, &l);
	vector<int> a;
	vector<int> b;
	int x[n];
	int y[n];
	scanf("%d", &x[0]);
	for (int i = 1; i < n; ++i) {
		scanf("%d", &x[i]);
		a.pp(x[i] - x[i-1]);
	}
	a.pp(l - x[n-1] + x[0]);
	scanf("%d", &y[0]);
	for (int i = 1; i < n; ++i) {
		scanf("%d", &y[i]);
		b.pp(y[i] - y[i-1]);
	}
	b.pp(l - y[n-1] + y[0]);

	int count = 0;
	for (int i = 0; i < n; ++i) {
		count = 0;
		for (int j = 0; j < n; ++j) {
			if(a[j] != b[j]){
				a.pp(a[0]);
				a.erase(a.begin());
				break;
			}
			count++;
		}
	}

	puts(count == n ? "YES" : "NO");
	return 0;
}

#include <iostream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
using namespace std;

int main()
{
	int n, l;
	cin >> n >> l;
	vector<int> s(n), s2(n);
	vector<int> a(n);

	for (int i = 0; i < n; i++)
		cin >> a[i];

	s[0] = a[0] + l - a[n - 1];
	for (int i = 1; i < n; i++)
		s[i] = a[i] - a[i - 1];

	for (int i = 0; i < n; i++)
		cin >> a[i];

	s2[0] = a[0] + l - a[n - 1];

	for (int i = 1; i < n; i++)
		s2[i] = a[i] - a[i - 1];

	bool flag = true;

	for (int sd = 0; sd < n && flag; sd++)
	{
		if (s == s2) flag = false;
		else
		{
			int t = s[0];
			for (int i = 0; i < n - 1; i++)
				s[i] = s[i + 1];
			s[n-1] = t;
		}
	}

	if (flag) cout << "NO"; else cout << "YES";
}

#include <bits/stdc++.h>
using namespace std;

int n, l;

bool checkequal(vector<int> a, vector<int> b, int sa, int sb) {
    for (int i = 0; i < (int) a.size(); ++i) {
        a[i] = ((a[i]-sa)%l+l)%l;
        b[i] = ((b[i]-sb)%l+l)%l;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    return a==b;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> l;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    bool flag = false;
    for (int k = 0; k < l; ++k) {
        for (int s = 0; s < l; ++s) {
            if (checkequal(a, b, k, s)) {
                flag = true;
                break;
            }
        }
    }
    string ans = flag == true ? "YES" : "NO";
    cout << ans << '\n';
    return 0;
}

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int n,l;
    cin>>n>>l;
    int a[n],b[n],aa[n],bb[n];
    int i;
    for(i=0;i<n;i++)
    cin>>a[i];
    for(i=0;i<n;i++)
    cin>>b[i];

    aa[0]=a[0]+l-a[n-1];
    bb[0]=b[0]+l-b[n-1];
    for(i=1;i<n;i++)
    {
        aa[i]=a[i]-a[i-1];
        bb[i]=b[i]-b[i-1];
    }
    int k;
    bool f;
    for(k=0;k<n;k++)
    {
        f=true;
        for(i=0;i<n;i++)
        {
            if(aa[(i+k)%n]!=bb[i])
            {
                f=false;
                break;
            }

        }
        if(f)
        {cout<<"YES";return 0;}

    }
    cout<<"NO";
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);
	int n, L;
	cin >> n >> L;
	vector<int>a;
	int st1;
	int prev = -1;
	for(int i = 0; i < n; i++){
		int val;
		cin >> val;
		if(i > 0){
			assert(prev != -1);
			a.push_back(val - prev);
		}
		prev = val;
		if(i == 0)
			st1 = val;
	}
	a.push_back(L - prev + st1);
	prev = -1;
	vector<int>b;
	for(int i = 0; i < n; i++){
		int val;
		cin >> val;
		if(i > 0){
			assert(prev != -1);
			b.push_back(val - prev);
		}
		if(i == 0)
			st1 = val;
		prev = val;
	}
	b.push_back(L - prev + st1);
	assert( (int)a.size() == (int)b.size());
	for(int i = 0; i < (int)a.size();i++){
		bool good = true;
		rotate(a.begin(), a.begin() + 1, a.end());
		for(int j = 0; j < (int)b.size(); j++)
		{
			if(a[j] != b[j])
				good = false;
		}
		if(good == true){
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
}

#include<bits/stdc++.h>
using namespace std;
bool check(int arr1[],int arr2[],int n)
{
 for(int i=0;i<n;i++)
 {
     if(arr1[i]!=arr2[i])
        return false;
 }
 return true;
}
int main(void)
{
    int n,l;
    cin>>n>>l;
    int arr1[n],arr2[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr1[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>arr2[i];
    }
    if(n==1)
    {
        printf("YES");
        return 0;
    }
    bool flag=false;
    flag=check(arr1,arr2,n);
    if(flag==true)
    {
        printf("YES");
        return 0;
    }
    for(int i=1;i<l;i++)
    {
     for(int i=0;i<n;i++)
     {
         if(arr1[i]==0)
             arr1[i]=l-1;
         else
           arr1[i]=arr1[i]-1;
     }
     sort(arr1,arr1+n);
     flag=check(arr1,arr2,n);
     if(flag==true)
     {
         break;
     }
    }
    if(flag==true)
        printf("YES");
    else
        printf("NO");
    return 0;
}

#include <iostream>

using namespace std;

int n,L;
int a[100],b[100];
bool checkpoint[100];

int main()
{
    scanf("%d%d",&n,&L);
    for(int i=0;i<n;i++) scanf("%d",a+i);
    for(int i=0;i<n;i++) scanf("%d",b+i);

    // build check point
    for(int i=0;i<n;i++) checkpoint[a[i]]=true;

    bool isOK=false;

    // find start postion
    for(int s=0;s<L;s++)
    {
        bool flag=true;
        for(int i=0;i<n;i++)
        {
            int p = (s+b[i])%L;
            if(checkpoint[p]) continue;
            else
            {
                flag=false;
                break;
            }
        }
        if(flag==true)
        {
            isOK=true;
            break;
        }
    }

    if(isOK==true) puts("YES");
    else puts("NO");

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,l,a[55],b[55],da[55],db[55],dc[55];
bool f;
bool check(bool x)
{
    if(!x)
    {
        for(int i=0;i<n;i++)
            if(da[i]!=dc[i]) return 0;
        return 1;
    }
    if(x)
    {
        for(int i=0;i<n;i++)
            if(da[i]!=db[i]) return 0;
        return 1;
    }
    return 0;
}
int main()
{
    cin>>n>>l;
    cin>>a[0];
    for(int i=1;i<n;i++)
    {
        cin>>a[i];
        da[i]=a[i]-a[i-1];
        if(da[i]<0) da[i]+=l;
    }
    da[0]=a[0]-a[n-1];
    if(da[0]<0) da[0]+=l;
    cin>>b[0];
    for(int i=1;i<n;i++)
    {
        cin>>b[i];
        db[i]=b[i]-b[i-1];
        if(db[i]<0) db[i]+=l;
    }
    db[0]=b[0]-b[n-1];
    if(db[0]<0) db[0]+=l;
    if(check(1))
    {
        cout<<"YES"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++)
    {
        f=i%2;
        if(f)
        {
            db[0]=dc[n-1];
            for(int j=1;j<n;j++)
                db[j]=dc[j-1];
        }
        else if(!f)
        {
            dc[0]=db[n-1];
            for(int j=1;j<n;j++)
                dc[j]=db[j-1];
        }
        if(check(f))
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}

#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<stack>
#include<map>
using namespace std;

ifstream in("input.txt");
ofstream out("output.txt");

vector<int>a;
vector<int>b;
int n,l;

int main(){
	cin >> n >> l;
	a.resize(n*2);
	for(int i = 0; i < n; i++){
		cin >> a[i];
		a[i+n] = a[i];
	}
	b.resize(n+1);
	for(int i = 0; i < n; i++){
		cin >> b[i];
	}
	b[n] = b[0] + l;
	for(int i = 0; i < n; i++){
		bool bo = true;
		for(int j = 0; j < n; j++){
			int f = b[j+1] - b[j];
			int s = a[i+j+1] - a[i+j];
			if(i + j == n - 1){
				s = a[i + j + 1] + l - a[i + j];
			}
			if(f != s){
				bo = false;
				break;
			}
		}
		if(bo){
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}

#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WAENINGS
#define Mapogo ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
typedef long long ll;
#define i(n) (int i=0;i<n;i++)
#define r(n) (int r=0;r<n;r++)
#define j(n) (ll j=0;j<n;j++)
#define yes cout<<"yes\n"
#define no cout<<"no\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
#define endl "\n"
#define Pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
//============== GCD ==================//
long long gcd(long long a, long long b)
{
	if (b == 0)
		return a;
	return gcd(b, a%b);
}
//============ Plaindrome =============//
//bool plaindrome(string s) {
//	for (int i = 0, j = s.size() - 1; i < s.size() / 2; i++, j--) {
//		if (s[i] != s[j])
//			return false;
//	}
//	return true;
//}
//============ in/out file ============//
//void file() {
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt","w",stdout);
//}
//============== Prime ===============//
//bool prime(ll n) {
//	if (n == 2)return true;
//	for (ll i = 2; i*i <= n; i++)
//		if (n%i == 0)return false;
//	return true;
//}
//bool oneway(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3) {
//	ll a = x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2);
//	if (a == 0)return true;
//	return false;
//}
int main()
{
	Mapogo;
	int n, l;
	cin >> n >> l;
	vector <int> kefa(n), sasha(n);
	for i(n)cin >> kefa[i];
	for i(n)cin >> sasha[i];
	bool x = 0;
	for i(l + 1) {
		bool is = 0;
		for i(n) {
			sasha[i]--;
			if (sasha[i] == -1) {
				sasha[i] = l - 1;
				is = 1;
			}
		}
		if (is)
			sort(sasha.begin(), sasha.end());
		if (kefa == sasha) {
			YES;
			x = 1;
			break;
		}
	}
	if (!x)NO;
//	system("pause");
}

#include <bits/stdc++.h>
/*
*
*
*    Author by Mouhanad
*
*/
using namespace std;
typedef long long ll;
#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
#define pb(x) push_back(x)
const int inf = 10000000 ;
const int MOD = 1000000007 ;
int n , m , k  , c = 1  , q  ;
int lp[202] ;
int a [55];
int b [55];
vector < int > v , u;
 deque < int > Dq ;
bool scan ( ){

for ( int i = 0 ; i < n; i++ )
        if ( v[i] != Dq[i] ) return 0;
return 1 ;
}
int main()
{
    scanf("%d%d" , &n , &k ) ;

   for ( int i = 0 ; i < n ; i++ ) { scanf("%d" , &(a[i])) ; }
   for ( int i = 0 ; i < n ; i++ ) { scanf("%d" , &(b[i])) ; }

   for ( int i = 1 ; i < n ; i++  ){ v.pb(a[i]-a[i-1]);}
    v.pb(a[0] + k - a[n-1]);

   for ( int i = 1 ; i < n ; i++  ){ Dq.pb(b[i]-b[i-1]);}
    Dq.pb(b[0]+ k - b[n-1]);

    bool f = 0 ;
    for ( int i = 0; i < n ; i++ ) {
         /* for ( auto x : v ) cout << x <<" " ;
          cout << endl ;
          for ( auto y : Dq ) cout << y <<" "  ;
          cout << endl << endl ;*/
          f = scan() ;
          int x = Dq.front() ;
          Dq.pop_front();
          Dq.pb(x);
          if (f) break;
    }
    if ( f ) printf("YES");
    else printf("NO");
      return 0 ;
}

/* Copyright (2016) A.K.S.H.*/

#include<bits/stdc++.h>

using namespace std;

#define pb push_back
#define lvec vector<int>

int main()
{
	std::ios_base::sync_with_stdio(false);

	bool flg=false;
	lvec v1, v2;
	int n,l,n1, t1, t2, f;
	cin>>n>>l;
	n1=n-1;
	cin>>t1;
	f=t1;
	t2=t1;
	while(n1--)
    {
        cin>>t2;
        v1.pb(t2-t1);
        t1=t2;
    }
    v1.pb(l-t2+f);
    n1=n-1;
	cin>>t1;
	f=t1;
	t2=t1;
	while(n1--)
    {
        cin>>t2;
        v2.pb(t2-t1);
        t1=t2;
    }
    v2.pb(l-t2+f);
    int i=0, j=0, cnt=0, it=0;
    for (int i=0; i<=n; i++)
    //while(true)
    {
        if(it==n)      break;
        if(i==n)
        {
            i=0;
        }
        if(j==n)
        {
            flg=true;
            break;
        }
        if(v1[i]!=v2[j])
        {
            j=0;
            it++;
            i=it-1;
        }
        else                j++;

    }
    if(flg) cout<<"YES";
    else    cout<<"NO";

	return 0;
}

#include <stdio.h>
#include <stdlib.h>

/*int cmp(const void *a, const void *b){
    return *(int*)a - *(int*)b;
}*/
int main()
{
    int i,j,fir,n,l,a,f,flag;
    int cmpa[110],cmpb[110];
    scanf("%d%d", &n, &l);
    scanf("%d",&fir);
    f = fir;
    for(i = 0; i < n - 1; i ++){
        scanf("%d",&a);
        cmpa[i] = a - f;
        f = a;
    }
    cmpa[i] = l - a + fir;

    scanf("%d",&fir);
    f = fir;
    for(i = 0; i < n - 1; i ++){
        scanf("%d",&a);
        cmpb[i] = a - f;
        f = a;
    }
    cmpb[i] = l - a + fir;

    if(n == 1){
        printf("YES\n");
        return 0;
    }

 /*   if(n == 2){
        if(cmpa[0] == cmpb[0]) printf("YES\n");
        else printf("NO\n");
    }
    else{
        qsort(cmpa, n, sizeof(cmpa[0]), cmp);
        qsort(cmpb, n, sizeof(cmpb[0]), cmp);
        for(i = 0; i < n; i ++){
            if(cmpa[i] != cmpb[i]){
                printf("NO\n");
                return 0;
            }
        }
        printf("YES\n");
    }*/
    for(i = n; i < 2 * n; i ++)  cmpb[i] = cmpb[i - n];

    for(i = 0; i < n; i ++){
        flag = 1;
        for(j = 0; j < n; j ++){
            if(cmpa[j] != cmpb[j + i])
                flag = 0;
        }
        if(flag){
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}

#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

int a[200];
int b[200];

int main(){
	int n,l;
	int c[200];
	int d[200];

	cin>>n>>l;
	for (int i=0 ; i<n; i ++){
		cin>>a[i];
	}

	for (int i=0; i<n ; i++){
		cin>>b[i];
	}

	for (int i=1 ; i<n ; i++){
		c[i]=a[i]-a[i-1];
		d[i]=b[i]-b[i-1];
	}

	for (int i=1 ; i<n ; i++){
		a[i]=c[i];
		b[i]=d[i];
	}

	int s=0;
	for (int i=1 ; i<n ; i++)
		s+=a[i];
	a[0]=l-s;

	s=0;
	for (int i=1; i<n ; i++)
		s+=b[i];
	b[0]=l-s;

	for (int i=0 ; i<n ; i++){
		for (int j=0 ; j<n ; j++){
			bool flag=false;
			if (a[i]==b[j]){
				flag=true;
				queue<int> q;
				for (int k=i ; k<n ; k++){
					q.push(a[k]);
				}
				for (int k=0 ; k<i ; k++){
					q.push(a[k]);
				}
				for (int k=j ; k<n ; k++){
					if (b[k]!=q.front()){
						flag=false;
						break;
					}
					else{
						q.pop();
					}
				}

				for (int k=0 ; k<j ; k++){
					if (b[k]!=q.front()){
						flag=false;
						break;
					}
					else{
						q.pop();
					}
				}
			}

			if (flag){
				cout<<"YES"<<endl;
				return 0;
			}

		}
	}

	cout<<"NO"<<endl;

	return 0;
}

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

void to_r(int *a, int sz)
{
	int b = a[sz - 1];
	for(int i = sz - 1; i > 0; i--)
		a[i] = a[i - 1];
	a[0] = b;
}

void arrpp(int *a, int sz, int L)
{
	for(int i = 0; i < sz; i++)
		if(++a[i] == L)
			a[i] = 0;
}

void inp_arr(int *a, int sz)
{
	for(int i = 0; i < sz; i++)
		cin >> a[i];
}

bool eq_arr(int *a, int *b, int sz)
{
	for(int i = 0; i < sz; i++)
		if(a[i] != b[i])
			return false;
	return true;
}
/*
int sum_arr(int *a, int sz)
{
	int sum = 0;
	for(int i = 0; i < sz; i++)
		sum += a[i];
	return sum;
}
*/

int main()
{
	int n, L, a[100], b[100];
	cin >> n >> L;
	inp_arr(a, n);
	inp_arr(b, n);
	for(int j = 0; j < n; j++)
	{
		for(int i = 0; i < L; i++)
		{
			arrpp(b, n, L);
			if(eq_arr(a, b, n))
			{
				cout << "YES" << endl;
				getchar();
				return 0;
			}
		}
		to_r(b, n);
	}
	cout << "NO" << endl;
	getchar();
	return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;

int n, L;
int A[60], B[60];

bool equal()
{
	sort(A, A+n);
	sort(B, B+n);

	for (int i = 0; i < n; i++)
		if (A[i] != B[i])
			return false;

	return true;
}

int main()
{
	cin >> n >> L;

	for (int i = 0; i < n; i++)
		cin >> A[i];

	for (int i = 0; i < n; i++)
		cin >> B[i];

	for (int i = 0; i < L + 1; i++)
	{
		for (int j = 0; j < n; j++)
		{
			B[j]--;

			if (B[j] < 0)
				B[j] = L - 1;
		}

		if (equal())
		{
			cout << "YES";
			return 0;
		}
	}

	cout << "NO";

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

vector <int> a;
vector <int> b;

void solve(int n, int l){
	int fl=0;

vector <int> x;
vector <int> y;

			x.push_back(l - a[n-1] + a[0]);

			for	(int i=1; i<n; i++){
				x.push_back(a[i] - a[i-1]);
			}

			y.push_back(l - b[n-1] + b[0]);

			for(int i=1; i<n; i++){
				y.push_back( b[i] - b[i-1]);
			}

bool flag;
	for(int i=0; i<n; i++){
	int pos = i;
	 flag = true;
		for(int j=0; j<n; j++){
			if (pos == n) pos = 0;
			if (x[pos] != y[j]) {
				flag=false;
				break;
			}
			pos++;
		}
		if (flag == true){
			//cout << "YES";
			break;
		}
	}
if (flag == false) cout << "NO"; else cout << "YES";
}
void read(){
	int n, l;
	scanf("%d%d", &n, &l);

	for(int i=0; i<n; i++){
		int x;
		scanf("%d", &x);
		a.push_back(x);
	}
	for(int i=0; i<n; i++){
		int x;
		scanf("%d", &x);
		b.push_back(x);
	}
	solve(n, l);
}
int main(){
	read();
return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N =1e6+6;
const long long M =1e9+7;
const double eps =1e-7;
#define go_baby_go ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define pb push_back
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector<int>
#define F(i,n) for(int i=1;i<=n;i++)
int a[N],b[N];
int Int(){int x;scanf("%d",&x);return x;}
ll Lnt(){ll x;scanf("%I64d",&x);return x;}
#define Int Int()
#define Lin Lnt()
ll Bigmod(ll A,ll B,ll C)
{
     if(B==0LL)return 1LL;
     ll x=Bigmod(A,B/2LL,C);
     x=(x*x)%C;
     if(B%2==1)
     x=(x*A)%C;
     return x;
}
struct mar
{
     int i,j,c,d;
}cr[N];
bool cmp(mar a,mar b){
     if(a.i==b.i)
     return a.j<b.j;
     return a.i<b.i;
}
bool Cmp(int a,int b){return a>b;}
void print(int n){printf("%d\n",n);}
void Print(ll n){printf("%I64d\n",n);}
void debug(int n){printf("%d ",n);}
int get(int p)
{
     int x=1,i=1;
     while(x<M)
     {
          int j=i;
          F(f,p-1)
          {
               j*=i;
          }
          a[i++]=j;
          x=j;
        //  debug(a[i-1]);
         // print(i-1);

     }
     return i-2;
}
int S(int n)
{
     int s=0;
     while(n)
     {
          s+=(n%10);
          n/=10;
     }
     return s;
}
int c[N],d[N];
void rotate(int n)
{
     int x=c[1];
     c[1]=c[n];
     for(int i=2;i<=n;i++)
     {
          int y=c[i];
          c[i]=x;
          x=y;
     }
}
int main()
{
     int n=Int,m=Int;
     F(i,n)
     {
          a[i]=Int;
     }
     F(i,n)
     {
          b[i]=Int;
     }
     int l=0,r=0;
     F(i,n)
     {
          if(i==1)
          {
               c[i]=(a[1]+m-a[n]);
               d[i]=(b[1]+m-b[n]);
          }
          else
          {
               c[i]=a[i]-a[i-1];
               d[i]=b[i]-b[i-1];
          }
     }
     F(i,n)
     {
          int j;
          for(j=1;j<=n;j++)
          {
               if(c[j]!=d[j])
               break;
          }
          if(j==n+1)
          return puts("YES"),0;
          rotate(n);
         /* F(i,n)
          debug(c[i]);
          puts("");*/
     }
     puts("NO");
}

#include<bits/stdc++.h>
using namespace std ;

int n,l ,flag=0,a[60] , b[60];
vector< int > v  , v1;

int main()
{
	cin>>n>>l;
	for(int i=0;i<n;i++)
	{
		int diff;
	   cin>>a[i] ;
	   if(i!=0)
	   {
	   	diff = a[i]  - a[i-1] ;

	   	v.push_back(diff) ;
	   }
	   	if(i==n-1)
	   	{
	   		diff = l-a[i]  + a[0];
	   		v.push_back(diff) ;
		   }
	}
	int flag=0,sum;
	for(int i=0;i<n;i++)
{
		cin>>b[i] ;
		int diff;
		 if(i!=0)
	   {
	   	diff = b[i]  - b[i-1] ;
	   	v1.push_back(diff);
	   }
	   	if(i==n-1)
	   	{
	   		diff = l-b[i] + b[0];
	   		v1.push_back(diff) ;
		   }

}
   for(int i=0;i<v.size() ;i++)
   {
   	  flag=0 ;
   	  for(int j=0;j<v1.size();j++)
   	  {
   	          if(v1[j] != v[(i+j)%v.size()])
				 {
				    flag=1 ;
					break ;
				 }
	  }
	  if(flag==0)
	  break;
   }
   if(flag==0)
   cout<<"YES\n";
   else
   cout<<"NO\n";
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int arr[1010],arr2[1010],copy1[1010],n,fixe=5,l,p=0,d,flag;
    cin >> n >> l;
    for(int i=0; i<n; i++)
        cin >> arr[i];

    for(int i=0; i<n; i++)
        cin >> arr2[i];
    fixe = -1;
    int k = n;
    if(n==1){cout<<"YES";return 0;}
    while(k--){
        flag = 1;
        p=0;
        for(int i=fixe+1; i<n; i++){
        if(i>(i+1)%n)p=l;
        if((arr2[0]+abs(arr[i%n]-(arr[(i+1)%n]+p)))==arr2[1])
                {fixe = i;break;}
        }
        if(fixe<0)break;
        p=0;
        for(int j=fixe,d=0; j<n+fixe;d++,j++){
            if((j+n)%n<fixe)p=l;
            copy1[d] = arr[j%n]+p;
        }
        for(int i=0; i<n-1; i++){
            if(abs(copy1[i]-copy1[i+1])==abs(arr2[i]-arr2[i+1]));
            else {flag = 2;break;}
        }
        if(flag==1){cout << "YES";return 0;}
    }
    cout << "NO";
    return 0;
}

#include<bits/stdc++.h>
#include <cstdio>//fill(a,a+n,0) copy(a,a+n,b) for array only
#include <algorithm>
using namespace std;
#define ll long long
#define pr pair<ll,ll>
#define mp make_pair
#define vi vector<ll>
#define vvi vector<vector<ll> >
#define vp vector<pr >
#define X first
#define Y second

int main(){
	if(fopen("input.txt","r")){
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	}
	int n,L;
	cin>>n>>L;
	vector<int> a(n),b(n),c(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>b[i];
	int flag=0,cur;
	for(int i=0;i<n;i++){
		c[i]=abs(a[(i+1)%n]-a[i]);
		if(i==n-1)
			c[i]=abs(L-a[n-1]+a[0]);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cur = (b[j] + c[(i+j)%n])%L;
			if(cur==b[(j+1)%n]){
				if(j==n-1){
					flag=1;
					break;
				}
			}
			else{
				flag=0;
				break;
			}
		}
		if(flag==1)
			break;
	}

	if(flag==1)
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
}

#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pb push_back
#define s second
#define f first
#define mp make_pair
#define mod 1000000007
using namespace std;
int main() {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	/*lld t=0;
	cin>>t;
	while(t--)
	{*/
        int ans=0,cnt=0,c=0;
        int n,i;
        cin>>n>>ans;
        int a[n];
        int b[n];
        for(i=0;i<n;i++)
            cin>>a[i];
        for(i=0;i<n;i++)
            cin>>b[i];
        for(i=0;i<n-1;i++)
        {
            a[i]=a[i+1]-a[i];
            cnt+=a[i];
            b[i]=b[i+1]-b[i];
            c+=b[i];
        }
        a[n-1]=ans-cnt;
        b[n-1]=ans-c;
        //sort(a,a+n);
        //sort(b,b+n);
        queue <int> q1,q2;
        for(i=0;i<n;i++)
        {
            q1.push(a[i]);
            q2.push(b[i]);
        }
        //cout<<endl;
        int x;
        bool flag=false;
        for(i=0;i<n;i++)
        {
            //cout<<q1.front()<<" ";
            if(q1==q2)
            {
                flag=true;
                break;
            }
            x=q1.front();
            q1.pop();
            q1.push(x);

        }
        if(flag)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
        /*lld arr[n];
            for(i=0;i<n;i++)
               cin>>arr[i];
        */
    //}
	return 0;
}
/*  CODED BY:-
           __        __
 /\   /\  |__)  /\  |  \ |__| \ /  /\
/~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\

*/

#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,l,x[55],y[55],nx[55],ny[55];
int main()
{
	while(~scanf("%d%d",&n,&l))
	{
		for(int i=1;i<=n;i++)
			scanf("%d",x+i);
		for(int i=1;i<=n;i++)
			scanf("%d",y+i);
		nx[1]=l-x[n]+x[1];
		ny[1]=l-y[n]+y[1];
		for(int i=2;i<=n;i++)
		{
			nx[i]=x[i]-x[i-1];
			ny[i]=y[i]-y[i-1];
		}
		bool flag=0;
		for(int i=0;i<n;i++)
		{
			bool temp=1;
			for(int j=1;j<=n;j++)
			{
				int xx=j;
				int yy=j+i;
				if(yy>n)
					yy-=n;
				if(nx[xx]!=ny[yy])
				{
					temp=0;
					break;
				}
			}
			if(temp)
			{
				flag=1;
				break;
			}
		}
		if(flag)
			puts("YES");
		else
			puts("NO");
	}
	return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define NN 111111

int a[55], b[55], c[55];

#define rep(i, n) for(i=0; i<n; i++)

int main(){

	int n, L, i, j, d;

	cin>>n>>L;

	rep(i, n) cin>>a[i];

	rep(i, n) cin>>b[i];

	int flag = 0;

	rep(i, n){

		rep(j, n){

			int x = ( a[j]-b[(i+j)%n]+L)%L;

			if(!j) { d = x;  }

 			if ( d != x ) break;

		}

		if( j == n ) { flag = 1; break; }

	}

	puts(flag? "YES" : "NO");

	return 0;

}

#include<bits/stdc++.h>
#define mx 105

using namespace std;
vector<int>v1;
vector<int>v2;
int arr[mx];
int n,l;

int main()
{
      cin>>n>>l;
      v1.clear();
      v2.clear();
      for(int i=0;i<n;i++)
      {
            cin>>arr[i];
            if(i)
                v1.push_back(arr[i]-arr[i-1]);
      }
      v1.push_back(l-arr[n-1]+arr[0]);

      for(int i=0;i<n;i++)
          v1.push_back(v1[i]);

      for(int i=0;i<n;i++)
      {
           cin>>arr[i];
           if(i)
              v2.push_back(arr[i]-arr[i-1]);
      }
      v2.push_back(l-arr[n-1]+arr[0]);

       for(int i=0;i<n;i++)
          v2.push_back(v2[i]);

       int sig=0;

       for(int i=0;i<n;i++)
       {
            int cnt=0;
            int k=0;
            for(int j=i;j<i+n;j++)
            {
                 if(v1[k++]==v2[j])
                     cnt++;
               // cout<<v1[j]<<" "<<v2[j]<<endl;
            }
          //  cout<<cnt<<endl;
            if(cnt==n)
            {
                 sig=1;
                 break;
            }
       }

       if(sig)
           cout<<"YES"<<endl;
       else
           cout<<"NO"<<endl;
       return 0;
}

#include <bits/stdc++.h>

using namespace std;
bool egal(int t[],int v[],int n)
{
    sort(t,t+n);
    bool test=true ;
    for(int i =0;i<n;i++)
    {
        if(t[i]!=v[i]){test=false ; break ;}
    }
    return test ;
}

int main()
{
    int n,L;
    cin>>n>>L;
    int t[n],v[n];
    for(int i=0;i<n;i++)
        cin >>t[i];
        for(int i=0;i<n;i++)
        cin >>v[i];

    bool test =false ;

    if (!egal(t,v,n))
    {
        for(int i=1;i<=L;i++)
        {
            for(int j=0;j<n;j++)
            {
               {

                t[j]=(t[j]-1)%L;
                if(t[j]<0) t[j]+=L;
               }
            }
            if(egal(t,v,n)){test=true;break;}

        }

    }
    else test=true ;

    if (test) cout <<"YES" ;
    else cout<<"NO";
    return 0;
}

// Abhay Singh Bhadoria ( _Asb_ ) //
#include<bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const int M = 1e9 + 7;
const int N = 50 + 5;
int k[N], s[N];
vector<int> ke, sa;
int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n, l;
    cin >> n >> l;
    for(int i = 0; i < n; ++i) {
        cin >> k[i];
    }
    k[n] = k[0];
    for(int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    s[n] = s[0];
    for(int i = 1; i <= n; ++i) {
        ke.push_back((k[i] - k[i - 1] + l) % l);
    }
    for(int i = 1; i <= n; ++i) {
        sa.push_back((s[i] - s[i - 1] + l) % l);
    }
    for(int i = 0; i <= n; ++i) {
        rotate(ke.begin(), ke.begin() + 1, ke.end());
        if(sa == ke) {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}

#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<string>
#define maxn 110
using namespace std;
int arr[maxn][2];
int brr[maxn];
int crr[maxn];

int main() {
	int l, n;
	memset(brr, 0, sizeof(brr));
	memset(crr, 0, sizeof(crr));
	cin >> n >> l;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &arr[i][0]);
		brr[i] = arr[i][0] - arr[i - 1][0];
	}
	brr[1] = l - arr[n][0]+arr[1][0];
	for (int i = 1; i <= n; i++) {
		scanf("%d", &arr[i][1]);
		crr[i] = arr[i][1] - arr[i - 1][1];
	}
	crr[1] = l - arr[n][1] +arr[1][1];

	int flag = 0;
	for (int i = 1; i <= n; i++) {
		if (brr[1] == crr[i]) {
			flag = 1;
			for (int j = 1; j <= n - 1; j++) {
				int pos = (i + j) % n;
				if (pos == 0)pos = n;
				if (brr[1 + j] != crr[pos]) { flag = 0; break; }
			}
			if (flag == 1)break;
		}
	}
	if (flag)cout << "YES" << endl;
	else { cout << "NO" << endl; }
}

#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#define pb push_back
#define ll long long int
#define vi vector<int>
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define insline(s) getline(cin,s)

using namespace std;

bool rev(int x,int y) //sort in reverse order
{
	return x>y;
}

template<class T>
void swap(T *a,T *b)  //Swap function
{
	T t;
	t = *a;
	*a = *b;
	*b = t;
}

long long pow_(long long a, int p)
{
    long long ans = 1;
    while(p)
    {
        if (p % 2) ans = ans * a % mod;
        a = a * a % mod;
        p /= 2;
    }
    return ans;
}

int main() {
	int l,n;
	cin>>n>>l;
	int array1[n],array2[n];
	for(int i=0;i<n;i++) cin>>array1[i];
	for(int i=0;i<n;i++) cin>>array2[i];

	char s1[n],s2[2*n];
	for(int i=0;i<n-1;i++) s1[i] = array1[i+1]-array1[i] + 'a';
	s1[n-1] = abs(l-array1[n-1]) + abs(array1[0]) + 'a';
//	cout<<s1;
	for(int i=0;i<n-1;i++) s2[i] = array2[i+1]-array2[i] + 'a';
	s2[n-1] = abs(l-array2[n-1]) + abs(array2[0]) + 'a';
	for(int i=0;i<n-1;i++) s2[i+n] = array2[i+1]-array2[i] + 'a';
	s2[2*n-1] = abs(l-array2[n-1]) + abs(array2[0]) + 'a';

//	cout<<s2;
	string s3=s1;
	string s4=s2;
//	cout<<s3<<"   "<<s4;
	int count=0;

	for(int j=0;j<n;j++){

	for(int i=0;i<s3.size();i++){
		if(s3[i]==s4[i+j]){
			count++;
		}
	}
	if(count==(n))
		break;
	else
		count=0;
	}

	if(count==(n))
	cout<<"YES";
	else cout<<"NO";

//	cout<<endl<<s3;
    return 0;
}

#include<bits/stdc++.h>
#define mp make_pair
#define SIZE 1000
#define pb push_back
#define INF 99999
#define ll long long
#define ak ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forin for(ll i=0;i<n;i++)
using namespace std;
int main()

{

     ll n,k;
     cin >> n >> k;
     ll a[n];
     ll b[n];
     set<ll> s;
     for(ll i=0;i<n;i++)
     {
         cin >> a[i];
     }
       for(ll i=0;i<n;i++)
     {
         cin >> b[i];
     }
      ll t=a[0];
    for(ll i=0;i<n;i++)
    {

    a[i]=a[i]-t;

    }

    for(ll i=0;i<n;i++)
    {
        ll tt =b[i];
          ll c[n];
          ll cont=0;
           fill(c,c+n,0);
        for(ll j=0;j<n;j++)
        {
            if(b[j]<b[i])
            {
                c[j]=k-(b[i]-b[j]);
            }
            else{
                c[j]=b[j]-b[i];
            }

        }
        sort(c,c+n);
        for(ll j=0;j<n;j++)
        {
            if(c[j]==a[j])
            {
                cont++;
            }
            else{
                break;
            }
        }
        if(cont==n)
        {
            cout << "YES";
            return 0;
        }

    }

 cout <<"NO ";
 return 0;
}

#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
	int n,l,bar1,bar2,tam;
	int *a=new int[105];
	int *b=new int[105];
	//freopen("list.txt","r",stdin);

	cin>>n>>l;
	cin>>bar1;
	tam=bar1;
	for (int i=1;i<n;i++)
	{
		cin>>bar2;
		a[i-1]=bar2-bar1;
		bar1=bar2;
	}
	a[n-1]=l-bar2+tam;

	cin>>bar1;
	tam=bar1;
	for (int i=1;i<n;i++)
	{
		cin>>bar2;
		b[i-1]=bar2-bar1;
		bar1=bar2;
	}
	b[n-1]=l-bar2+tam;

	if (n==1)
		cout<<"YES\n";
	else
	{
		tam=0;
		int check=0,dem=0;
		for (int i=0;i<n;i++)
		{
			dem=0;
			if (a[tam]==b[i])
			{
				int j=i;
				while (dem<n-1)
				{
					j++;
					dem++;
					if (j>=n)
						j=j-n;
					if (a[tam+dem]!=b[j])
						break;
				}
				if (dem==n-1)
				{
					check=1;
					break;
				}
			}
		}

		if (check==1)
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}
}

#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int n,l,p;
    vector<int>k,s;
	cin>>n>>l;
	for (int i=0; i<n; i++)
	{
		cin>>p;
		k.push_back(p);
	}
	for (int i=0; i<n; i++)
	{
		cin>>p;
		s.push_back(p);
	}
    if (n==1)
    {
        cout<<"YES";
        return 0;
    }
	for (int i=0; i<n+1; i++)
    {
        int flag=0;
        if (k[0]==s[0])
            {
                for (int m=1; m<n; m++)
                {
                    if (k[m]!=s[m]) {flag=1;}
                }
                if (flag==0) {cout<<"YES"; return 0;}
            }
        while (k[0]!=0)
        {
            int flag=0;
            for(int j=0; j<n; j++)
            {
                k[j]--;
            }
            if (k[0]==s[0])
            {
                for (int m=1; m<n; m++)
                {
                    if (k[m]!=s[m]) {flag=1;}
                }
                if (flag==0) {cout<<"YES"; return 0;}
            }
        }
        k[0]=k[1]-1;
        for(int t=1; t<n-1; t++)
        {
            k[t]=k[t+1]-1;
        }
        k[n-1]=l-1;
        flag=0;
        if (k[0]==s[0])
            {
                for (int m=1; m<n; m++)
                {
                    if (k[m]!=s[m]) {flag=1;}
                }
                if (flag==0) {cout<<"YES"; return 0;}
            }
    }
    cout<<"NO";
    return 0;
}

#include<iostream>
#include<fstream>
#include<cmath>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include<vector>
#include<string>
#include <queue>
using namespace std;
typedef long long ll ;
int main()
{
	int a , b ;
	cin >> a >> b ;
	string s1 = ""  , s2 = "" ;

	long long arr[51] , arr1[51];
	for(int i=0;i<a;i++)
	{
		cin >> arr[i];
	}
	for(int i=0;i<a;i++)
	{
		cin >> arr1[i];
	}

	for(int i=0;i<a;i++)
	{
		if( i == a-1)
		{
			s1 += to_string(b - arr[i] + arr[0]) ;
		}else
		{
			s1 += to_string(arr[i+1] - arr[i]);
		}
	}

	for(int i=0;i<a;i++)
	{
		if( i == a-1)
		{
			s2 +=to_string( b - arr1[i] + arr1[0]);
		}else
		{
			s2 += to_string(arr1[i+1] - arr1[i]);
		}
	}

	string k = s1 ;
	char temp;
	string t = "" ;
	for(int i=0;i<k.length() ; i++)
	{
		if( k == s2 )
		{
			cout << "YES";
			return 0;
		}

		temp = k[0];
		t="";
		for(int i=1;i<k.length();i++)
			t+= k[i];
		t+= temp ;
		k = t ;
	}

	cout << "NO";
	return 0;
}

#include <bits/stdc++.h>

#define ll long long
#define mod (1e+9)+7
#define F first
#define S second
#define ii pair<ll , ll>
#define vii vector<ii >
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define trav(s , it) for(auto& it : s)
#define all(x) x.begin(),x.end()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define FixTo(x , y) cout.precision(y),cout << fixed << x
#define retToDef cout << defaultfloat
#define Montazer ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using namespace std;

ll dig2 (ll n){
 return log2(n)+1;
}

int main () {
 Montazer
 int n , l;
 cin >> n >> l;
 int ar1[55] , ar2[55];
 vector <int> a , b;
 for (int i=0 ; i<n ; i++){
  cin >> ar1[i];
  if (i>0){
   a.pb(ar1[i]-ar1[i-1]);
  }
 }
 a.pb((l-ar1[n-1])+ar1[0]);
 for (int i=0 ; i<n ; i++){
  cin >> ar2[i];
  if (i>0){
   b.pb(ar2[i]-ar2[i-1]);
  }
 }
 b.pb((l-ar2[n-1])+ar2[0]);
 bool ok = false;
 for (int i=0 ; i<n ; i++){
  if (b[i]==a[0]){
   int idx = i;
   for (int j=0 ; j<n ; j++){
    if (a[j]!=b[idx]) break;
    idx++;
    if (idx==n) idx=0;
    if (j==n-1)ok=true;
   }

  }
   if (ok){
    cout << "YES";
    break;
   }
 }
 if (!ok)cout << "NO";
 return 0;
}

/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define gcd(a,b) __gcd(a,b)
#define TEST int t;cin>>t;while(t--)
const long long int p = 1e9+7;
typedef unsigned  long long int ll;
#define INF 1000000000
#define ss second
#define ff first
using namespace std;
using namespace std;
#define ll long long
ll n,l,arc[100100],brc[100100];
int main()
{
    cin >> n >> l;
    for(int i = 0; i < n;i++)
        cin >> arc[i];
    for(int i = 0; i < n;i++)
    cin >> brc[i];
    bool ok = true;
    for(int i = 0; i < n; i++)
    {
    	ok=true;
    	int p=(arc[0] + l - brc[0 + i])%l;
    	for(int j = 1; j < n;j++)
    	{
    		if((arc[j] + l - brc[( j + i ) % n]) % l != p)
    		{
    			ok=false;
    			break;
    		}
    	}
    	if(ok)
    	{
    		cout << "YES" << endl;
    		return 0;
    	}
    }
    cout << "NO" << endl;
return 0;
}

#include <iostream>

using std::cout;
using std::cin;

bool a1[200], a2[100];

int main() {
    int i, j, t, n, l, first = -1;
    cin >> n >> l;
    for (i = 0; i < n; ++i) {
		cin >> t;
		a1[t] = true;
		a1[t + l] = true;
	}
    for (i = 0; i < n; ++i) {
		cin >> t;
		a2[t] = true;
	}
	bool found;
	for (i = 0; i < l; ++i) {
		found = true;
		for (j = 0; j < l; ++j) {
			if (a1[j + i] != a2[j]) {
				found = false;
				break;
			}
		}
		if (found) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

bool isrotation(int a[],int b[] ,int n){
	int res[210];
	int count = 0;
	for(int i = 1;i<=n;i++){
		res[i] = a[i];
		//cout<<res[i];
	}
	for(int i = n+1,k = 1;i<=2*n;i++,k++){
		res[i] = a[k];
		//cout<<res[i];
	}
	for(int i = 1;i<=n+1;i++){
		for(int j = 1,k = i;j<=n;j++,k++){
			if(count==n) return 1;
			if(res[k]==b[j]){
				count++;
				//cout<<"i :"<<i<<" and j :"<<j<<" and count :"<<count<<endl;
			}
			else
			{   //cout<<"here we encounter a break statement\n";
			    count = 0;
				break;
			}
		}
	}

	return 0;
}
int main(){
int n,l,r,k,s;
int a[105];
int b[105];
int x[105];
int y[105];
	cin>>n>>l;
	for(int i = 1;i<=n;i++){
		cin>>a[i];
	}
	for(int i = 1;i<=n;i++){
		cin>>b[i];
	}
	if(n==1){
		cout<<"YES";
		return 0;
	}
	k = 1;
	for(int i = 2;i<=n;i++){
	   x[k] = a[i]-a[i-1];
	   y[k]	= b[i]-b[i-1];
	   k++;
	}

		r = a[1] + (l-a[n]);
	    s = b[1] + (l-b[n]);
	    x[k] = r;
	    y[k] = s;

	int ans = isrotation(x,y,n);
	if(ans) cout<<"YES";
	else cout<<"NO";
	return 0;
}

/*
4 14
2 4 9 12     2 5 3 4
1 6 10 13    5 4 3 2

3 8
2 4 6       2 2 4
1 5 7       4 2 2

*/

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, l;
    cin >> n >> l;
    bool ch = 1;
    vector <int> a(n);
    vector <int> b(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++){
        cin >> b[i];
        if(a[i] != b[i])
            ch = 0;
    }
    if(ch){
            cout << "YES";
            return 0;
    }
    for(int i = 0; i < l; i++){
        ch = 1;
        for(int j = 0; j < n; j++)
            a[j] = (a[j] - 1 + 2* l)%l;
        sort(a.begin(), a.end());
        for(int j = 0; j < n; j++){
            if( a[j] != b[j]){
                ch = 0;
            }
        }
        if(ch){
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int a[100001];
int b[100001];
vector <int> v;
vector <int> v1;

int main () {
	int n, l;
	cin >> n >> l;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
	}
	for (int i = 1;i <= n;i ++) {
		cin >> b[i];
	}
	for (int i = 2;i <= n;i ++) {
		v.push_back (a[i] - a[i - 1]);
	}
	v.push_back (l - a[n] + a[1]);
	for (int i = 2;i <= n;i ++) {
		v1.push_back (b[i] - b[i - 1]);
	}
	v1.push_back (l - b[n] + b[1]);
	for (int i = 2;i <= n;i ++) {
		v1.push_back (b[i] - b[i - 1]);
	}
	v1.push_back (l - b[n] + b[1]);
	for (int i = 0;i < v1.size ();i ++) {
		int cur = i;
		bool ok = 0;
		for (int j = 0;j < v.size ();j ++) {
			if (v1[cur] != v[j]) ok = 1;
			cur ++;
		}
		if (!ok) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}

#include <iostream>
using namespace std;
int x[1001], v[1001], n, l;

void permcirc(int v[], int n)
{
    int aux=v[1], i;
    for(i=1; i<n; i++)
    {
        v[i]=v[i+1];
    }
    v[n]=aux;
}

void read()
{
    int a=0, start, i, b=0;
    cin>>n>>l;
    for(i=1; i<=n; i++)
    {
        b=a;
        cin>>a;
        if(i>1)
        {
            v[i]=a-b;
        }
        else start=a;
    }
    v[1]=l-(a-start);
    b=0;
    a=0;
    for(i=1; i<=n; i++)
    {
        b=a;
        cin>>a;
        if(i>1)
        {
            x[i]=a-b;
        }
        else start=a;
    }
    x[1]=l-(a-start);
}

void sol()
{
    int i, j, ok=1;
    for(i=1; i<=n; i++)
    {
        ok=1;
        for(j=1; j<=n; j++)
        {
            if(v[j]!=x[j])
            {
                ok=0;
            }
        }
        if(ok==1)
        {
            cout<<"YES";
            break;
        }
        permcirc(v, n);
    }

    if(ok==0) cout<<"NO";
}

int main()
{
    int i;
    read();
    sol();
    return 0;
}

#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
const long long MOD = 1000000007;
struct kom {
	int p, t;
};
int n,f, k=0,OT, i, j,l, a1, b1,a2,b2,a3,b3;
int x, a[1001] = { 0 }, b[1001] = { 0 };
void main() {
	cin >> n >> l;
	cin >> a1;
	a2 = a1;
	for (int i = 1; i < n; i++) {
		cin >> a3;
		a[i] = a3 - a2;
		a2 = a3;
	}
	a[0] = a1 + l - a2;
	cin >> a1;
	a2 = a1;
	for (int i = 1; i < n; i++) {
		cin >> a3;
		b[i] = a3 - a2;
		a2 = a3;
	}
	b[0] = a1 + l - a2;
	for (i = 0; i < n; i++) {
		f = 0;
		for (j = 0; j < n; j++)
			if (a[j] != b[(i + j) % n])
				f = 1;
		if (f == 0) {
			cout << "YES";
			return;
		}
	}
	cout << "NO";
//system("pause");
}

#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
#define INF 9223372036854775807
#define pmp(x,y) push_back(make_pair(x,y))
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define ld double
#define PI 3.14159265
#define len(a) (ll)a.size()
#define F first
#define S second
#define ch cout<<"debug\n"
#define cin(x) scanf("%lld",&x);
using namespace std;
ll a[200],b[200],c[200],d[200],e[201];
int main()
{
	ll n,l;
	cin>>n>>l;

	//n>2
	for(ll i=0;i<n;i++)
		cin>>a[i];

	for(ll i=0;i<n;i++)
		cin>>b[i];

	if(n==1)
	{
		cout<<"YES";
		return 0;

	}

	for(ll i=0;i<n-1;i++)
		c[i]=a[i+1]-a[i];

	c[n-1]=l-a[n-1]+a[0];

	for(ll i=0;i<n-1;i++)
		d[i]=b[i+1]-b[i];

	d[n-1]=l-b[n-1]+b[0];

	ll flag=0;

		for(ll j=0;j<n;j++)
		{

			if(c[0]==d[j])
			{
				ll k=0;
				for(k=0;k<n;k++)
				{
					if(c[k]!=d[(j+k)%n])
						break;
				}

				if(k==n)
				{
					flag=1;
					break;
				}

			}
		}

	if(flag==1)
	cout<<"YES";
	else
	cout<<"NO";

	return 0;
}

///Bismillahir Rahmanir Rahim
///ALLAHU AKBAR
#include<bits/stdc++.h>
#define flash() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define sc1i(a) scanf("%d",&a)
#define sc2i(a,b) scanf("%d %d",&a,&b)
#define   sc3i(a,b,c)       scanf("%d %d %d",&a, &b, &c)
#define    p1i(a)           printf("%d\n",(a))
#define    p2i(a,b)        printf("%d %d\n",(a), (b))
#define    p3i(a,b,c)      printf("%d %d %d\n",(a), (b), (c))

#define sc1l(a) scanf("%lld",&a)
#define sc2l(a,b) scanf("%lld %lld",&a,&b)
#define   sc3l(a,b,c)       scanf("%lld %lld %lld",&a, &b, &c)
#define    p1l(a)           printf("%lld\n",(a))
#define    p2l(a,b)        printf("%lld %lld\n",(a), (b))
#define    p3l(a,b,c)      printf("%lld %lld %lld\n",(a), (b), (c))

#define c(x)       cout<<x<<endl
#define cy  cout<<"YES"<<endl
#define cn   cout<<"NO"<<endl
#define f1(i,a,b)  for(ll i=a;i<b;i++)
#define f2(i,a,b) 	for(ll i=a;i<=b;i++)
#define fr(i,a,b)   for(ll i=a;i>=b;i--)
#define LCM(a,b)                (a / __gcd(a,b) ) *b
#define GCD(a,b)                __gcd(a,b)
#define dist(x1,y1,x2,y2)       sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define distl(x1,y1,x2,y2)      sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))

#define geta(a,n)           for(int i=0;i<n;i++) cin>>a[i]
#define puta(a,n)           for(int i=0;i<n;i++) cout<<a[i]<<" "

#define geta1(a,n)           for(int i=1;i<=n;i++) cin>>a[i]
#define puta1(a,n)           for(int i=1;i<=n;i++) cout<<a[i]<<" "

#define getar(a,n)           for(int i=0;i<n;i++) scanf("%lld",&a[i])
#define getar1(a,n)           for(int i=1;i<=n;i++) scanf("%lld",&a[i])
#define putar(a,n)           for(int i=0;i<n;i++) printf("%lld ",a[i])
#define putar1(a,n)           for(int i=1;i<=n;i++) printf("%lld ",a[i])
#define all(a)                  a.begin(),a.end()
#define lla(A)                  A.rbegin(), A.rend()
#define unique(a)               sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb                      push_back
#define mk                      make_pair
#define ff                      first
#define ss                      second
#define greatersrt(v)  sort(v.begin(),v.end(),greater<ll>())
#define min3(a,b,c)             min(a,min(b,c))
#define min4(a,b,c,d)           min(a,min(b,min(c,d)))
#define max3(a,b,c)             max(a,max(b,c))
#define max4(a,b,c,d)           max(a,max(b,max(c,d)))
#define max5(a,b,c,d,e)         max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)         min(min3(a,b,c),min(d,e))
#define mem(a,x)                memset(a,x,sizeof(a))
#define see_you                     return 0
#define sorta(a,n)                   sort(a,a+n)
#define SORT(v)                 sort(v.begin(),v.end())
#define REV(v)                  reverse(v.begin(),v.end())
#define gp ' '
#define nl                        printf("\n")
int caseno=0;

#define  printcase             printf("Case %d: ",++caseno)
#define Debug                   cout<<endl<<"AND I AM IRONMAN"<<endl;
#define binleastsigonebit(x)    __builtin_ffs(x)
#define binleadingzeroes(x)     __builtin_clz(x)
#define bintrailingzeroes(x)    __builtin_ctz(x)
#define bintotalones(x)         __builtin_popcount(x)

//Datatypes
#define ll                      long long
#define ULL                     unsigned long long
#define LD                      long double
#define UI                      unsigned int
#define US                      unsigned short
#define pii             pair<int,int>
#define pll             pair<ll,ll>

//Constants
const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const ll inf = 0xFFFFFFFFFFFFFFFL;
const int maxn = 211111;
const int N = 1111111;
#define PI                      acos(-1.0)
#define EulerGamma              0.57721566490153286060651209

//ll powmod(ll base, ll power) { if (power == 0) return 1; else {ll cur = powmod(base, power / 2); cur = cur * cur; cur = cur % MOD;if (power % 2 == 1) cur = cur * base; cur = cur % MOD; return cur;}

///-----------------------------GRAPH MOVES----------------------------////
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/
///ceil(x/y)==(x+y-1)/y

///-----------------------------VARIOUS FUNCTIONS----------------------------////

bool isprime(long long int n)
{
    bool flag = true;
    for(long long int i = 2; i*i <= n; ++i)
        //for(int i = 2; i <= sqrt(n); ++i)
        //for(int i = 2; i <= n/2; ++i)
    {
        if(n%i == 0)
        {
            flag = false;
            break;
        }
    }
    return flag;
}

bool ispoweroftwo (ll x)
{
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));
}

using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

//from a loser
ll a[200],b[200],vis[200];
ll n,l;

int main()
{
    flash()
    ll i,j,t,cas=0,k;
    cin>>n>>l;

    f1(i,0,n) {cin>>a[i]; vis[a[i]]=1; }
    f1(i,0,n) {cin>>b[i]; }

    int f;
    for(i=0;i<l;i++)
    {
         f=1;
        ll pos=i;
        for(j=0;j<n;j++)
        {
            ll x=(b[j]+pos)%l;
            if(!vis[x]) {f=0;break;}
        }
        if(f) break;
    }

    if(f) cy;
    else cn;

    see_you;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[200];
int b[200];
int main(){
	int n, L;
	cin >> n >> L;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		cin >> b[i];
	a[n] = a[0] + L - a[n -1] ;
	for(int i = 0; i < n -1; i++)
	{
		a[i] = a[i+1] - a[i];
		//cout << a[i]<< endl;
	}
	a[n-1] = a[n];
	//cout << a[n -1] <<endl;
	b[n] = b[0] + L - b[n - 1];
	for(int i = 0; i < n -1; i++)
	{
		b[i] = b[i+1] - b[i];
		//cout << b[i]<< endl;
	}
	b[n - 1] = b[n];
	//cout << b[n-1 ]<< endl;
	bool flag  = 1;
	for(int i = 0; i< n; i++){
		for(int j = 0; j < n;j++){
			flag  = 1;
			for(int k = 0; k < n; k++){
				if(a[(k + i) % n] != b[(k + j) % n]){
					flag = 0;
					break;
				}
			}
			if(flag == 1)
				break;
		}
		if(flag == 1)
			break;
	}
	if(flag == 1) cout << "YES";
	else cout<< "NO";
}

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> v;
typedef vector<ll> vl;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define inf (int)1e9
#define pb push_back
#define mp make_pair
#define gcd(a,b) (__gcd((a),(b)))
#define print(x) cout << (x) << endl

ll lcm(ll a,ll b)
{
	ll x=__gcd(a,b);
	a/=x;
	b/=x;
	ll sum=a*b*x;
	return sum;
}

bool is_prime(int n) {
    if (n == 1) {
        return false;
    }
    int i = 2;
    while (i*i <= n) {
        if (n % i == 0) {
            return false;
        }
        i += 1;
    }
    return true;
}

int main()
{
    int n,l,flag=0,pm=0;
    cin>>n>>l;
    int a[n],b[n],c[n];
    rep(i,n)
    {
        cin>>a[i];
        c[i]=a[i];
    }
    rep(i,n)
    {
        cin>>b[i];
    }
    for(int i=1;i<=l;i++)
    {
        rep(j,n)
        {
            if(c[j]-i<0)
            {
                c[j]=l+(c[j]-i);
            }
            else
            {
                c[j]=c[j]-i;
            }
        }
        sort(c,c+n);
        rep(i,n)
        {
            if(b[i]!=c[i])
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            cout<<"YES";
            pm=1;
            break;
        }
        rep(i,n)
        {
            c[i]=a[i];
        }
        flag=0;
    }
    if(pm==0)
    {
        cout<<"NO";
    }
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

int a[55], b[55];
int da[110], db[110];
int main(){
    //freopen("in.txt", "r", stdin );
    int n, l;
    while( scanf("%d %d", &n, &l ) != EOF ){
        for( int i = 1; i <= n; i++ ){
            scanf("%d", &a[i]);
        }
        a[n+1] = a[1] + l;
        for( int i = 1; i <= n; i++ ){
            scanf("%d", &b[i]);
        }
        b[n+1] = b[1] + l;
        for( int i = 1; i <= n; i++ ){
            da[i+n] = da[i] = a[i+1] - a[i];
            db[i+n] = db[i] = b[i+1] - b[i];
        }
        int flg = 0, f ;
        for( int i = 1; i <= n; i++ ){
            f = 1;
            for( int j = 1, idx = i ; j <= n; j++, idx++ ){
                if( da[idx] != db[j] ){
                    f = 0;
                    break;
                }
            }
            if( f ){
                flg = 1;
                break;
            }
        }
        if( flg ){
            puts("YES");
        }
        else{
            puts("NO");
        }
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l,d;
    cin>>n>>l;
    int arr[n],ar[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    int c=0,k=0,temp;
    for(int i=0;i<l;)
    {
        while(i>arr[c%n]){if(i>arr[n-1]){c=0;break;}c++;}
            temp=c;
            for(int j=0;j<n;j++)
            {
                if((l+(arr[c%n]-i))%l==ar[j])
                {
                    k++;c++;
                }
                else{k=0;c=temp;i++;break;}
            }
        if(k==n){cout<<"YES";return 0;}
    }
    cout<<"NO";
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    int y, n, l, a[1000], b[1000], counter = 0;
    cin >> n >> l;
    for(int i = 0; i < n; i++)
        cin >> a[i];

    for(int i = 0; i < n; i++)
        cin >> b[i];

    for(int i = 0; i < n; i++){
        for(y = 1; y < n; y++){
            if((a[i] - b[0] + l)%l != (a[(y+i)%n] - b[y] + l)%l)
                break;
        }
        if(y == n){
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}

#include <bits/stdc++.h>
using namespace std;
const int inf=1e9;
int main(){
    int n,l;
    cin>>n>>l;
    int k[n],s[n];
    for(int i=0;i<n;++i)cin>>k[i];
    for(int i=0;i<n;++i)cin>>s[i];
    if(n==1){
        cout<<"YES"<<endl;
        return 0;
    }
    vector<int> v,vv;
    int total=l;

    for(int i=1;i<n;++i){
        v.push_back(k[i]-k[i-1]);
    }
    int rem=total-k[n-1];
    v.push_back(rem+k[0]);

    for(int i=1;i<n;++i){
        vv.push_back(s[i]-s[i-1]);
    }
    rem=total-s[n-1];
    vv.push_back(rem+s[0]);
    string s1,s2;
    for(int i=0;i<v.size();++i){
        s1+=to_string(v[i]);
        s2+=to_string(vv[i]);
    }
    s1=s1+s1;
    if(s1.find(s2)!=string::npos){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;

}

#include <stdio.h>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>

using namespace std;

/*
ifstream in("input.txt");
ofstream out("output.txt");
#define cin in
#define cout out
/**/

int main()
{
	int n, l;
	cin >> n >> l;
	vector<int> a(n), b(n);
	vector<int> c(l, 0);
	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
		c[a[i]]++;
	}
	for(int i = 0; i < n; ++i)
		cin >> b[i];

	for(int i = 0; i < l; ++i)
	{
		vector<int> d(l, 0);
		for(int j = 0; j < n; ++j)
			d[(b[j] + i) % l]++;
		bool ok = 1;
		for(int j = 0; j < l; ++j)
			if(d[j] != c[j])
				ok = false;
		if(ok)
			return cout << "YES\n", 0;
	}
	cout << "NO\n";

}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int i , j , n , l , x , y;
    int a[500],b[500],difa[500],difb[500];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));

    scanf("%d %d",&n,&l);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    for(i=0;i<n;i++)scanf("%d",&b[i]);

    for(int k=0;k<l+1;k++){

            for(i=0;i<n;i++){
                a[i]++;
                a[i]%=l;
            }
            sort(a,a+n);
            bool ok = true;
            for(j=0;j<n;j++){
                if(a[j]!=b[j]){ok=false;break;}
            }
            if(ok){cout<<"YES"<<endl; return 0  ;}
    }

    cout<<"NO"<<endl;

    return 0;
}

#include<bits/stdc++.h>
#define pb push_back
using namespace std;

int main()
{
    std::ios::sync_with_stdio(0);
    int n , L , j;cin >> n >> L;
    int A[n] , B[n] ;
    vector< int > a , b;
    for(int i = 0 ;i < n;i++)   cin >> A[i];
    for(int i = 0 ;i < n;i++)   cin >> B[i];

    for(int i = 1 ;i < n;i++)   a.pb(A[i] - A[i - 1]);
    for(int i = 1 ;i < n;i++)   b.pb(B[i] - B[i - 1]);

    a.pb(L - A[n-1] + A[0]);
    b.pb(L - B[n-1] + B[0]);

    string ans = "NO";
    int fl = 0;
    for(int i = 0; i < n; i++)
    {
        for(j = 0;j < n;j++)
        {
            if(a[(i + j) % n] != b[j])
            {
                break;
            }
        }
        if(j == n)
        {
            ans = "YES";
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#include <algorithm>
using namespace std;
int check(int a[],int b[],int n);
int main()
{  int leng,n,k=0;
cin>>n>>leng;
  int a[51]={0},b[51]={0},c[51]={0},d[51]={0};
  for(int i=0;i<n;i++)
  {
      cin>>a[i];
  }
  for(int i=0;i<n;i++)
  {
      cin>>b[i];
  }

  c[0]=a[0]+(leng-a[n-1]);
  d[0]=b[0]+(leng-b[n-1]);
  for(int i=1;i<n;i++)
  {
      c[i]=a[i]-a[i-1];
      d[i]=b[i]-b[i-1];
  }

  if(check(c,d,n)==1)
    cout<<"YES";
  else
    cout<<"NO";
}
int check(int a[],int b[],int n)
{
    int i,k,checker=0,s=0;
    for(i=0;i<n;i++)
    {
        if(a[0]==b[i])
        {
           s=1;
           for(int j=0;j<n-i;j++)
           {
               if(a[j]!=b[j+i])
                s=0;

           }
                if(s==1)
                    for(int x=0;x<i;x++)
                  {
                    if(a[n-i+x]!=b[x])
                        s=0;
                  }
                if(s==1)
                    checker=1;

        }
    }
    return checker;
}

#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
	int n,l,bar1,bar2,tam;
	int *a=new int[105];
	int *b=new int[105];
	//freopen("list.txt","r",stdin);

	cin>>n>>l;
	cin>>bar1;
	tam=bar1;
	for (int i=1;i<n;i++)
	{
		cin>>bar2;
		a[i-1]=bar2-bar1;
		bar1=bar2;
	}
	a[n-1]=l-bar2+tam;

	cin>>bar1;
	tam=bar1;
	for (int i=1;i<n;i++)
	{
		cin>>bar2;
		b[i-1]=bar2-bar1;
		bar1=bar2;
	}
	b[n-1]=l-bar2+tam;

	if (n==1)
		cout<<"YES\n";
	else
	{
		tam=0;
		int check=0,dem=0;
		for (int i=0;i<n;i++)
		{
			dem=0;
			if (a[tam]==b[i])
			{
				int j=i;
				while (dem<n-1)
				{
					j++;
					dem++;
					if (j>=n)
						j=j-n;
					if (a[tam+dem]!=b[j])
						break;
				}
				if (dem==n-1)
				{
					check=1;
					break;
				}
			}
		}

		if (check==1)
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}
}

#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define i(n) scanf("%d",&n)
#define il(n) scanf("%lld",&n)
#define f(n) scanf("%f",&n)
#define d(n) scanf("%lf",&n)
#define c(n) scanf("%c",&n)
#define s(n) scanf("%s",n)
#define N 100005
#define INF 1000000000
#define pb push_back
#define ll long long
#define ull unsigned long long
#define REP(i,a,b)\
		for(int i = a ; i < b ; ++i)
#define REW(i,a,b)\
        for(int i = a-1 ; i >= b ; --i)

int a[101],b[101];

int main()
{
    int n,l;
    bool flag = true;
    i(n),i(l);
    int kef[n+1],sash[n+1];
    REP(i,0,n)
        {
        i(kef[i]);
        a[kef[i]] = 1;
    }
    REP(i,0,n)
        {
        i(sash[i]);
        b[i] = sash[i];
    }

    int tmp;
	for(int dis = 0 ; dis < l ; ++dis)
    {
		tmp = dis;
		for(int i = 0 ; i < n ; ++i)
        {
			if(tmp + b[i] >= l)
				tmp -= l;
			if(a[tmp+b[i]] != 1)
				break;
			if(i == n-1)
            {
				printf("YES\n");
				return 0;
			}
		}
	}
	printf("NO\n");

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define rsrt(s) sort(s.rbegin(),s.rend())
#define all(x) x.begin(),x.end()
#define mem(a, b) memset(a, b, sizeof(a))

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    ll n,l;
    cin >> n >> l;

    vector <ll > a(n),b(n),c(n),d(n);

    for(auto &i : a) cin >> i;
    for(auto &i : b) cin >> i;

    for(ll i=1;i<=n;i++)
    {
        if(i==n)
        {
            c[i-1]=l-a[n-1]+a[0];
            d[i-1]=l-b[n-1]+b[0];
        }
        else
        {
            c[i-1]=a[i]-a[i-1];
            d[i-1]=b[i]-b[i-1];
        }

    }

    ll i,j;
    for(i=0;i<n;i++)
    {
        for( j=0;j<n;j++)
        {
            if(c[j]!=d[(i+j)%n]) break;
        }
        if(j==n) return cout << "YES\n",0;
    }

    cout << "NO\n";

    //---------------------------------

    return 0;
}

#include <bits/stdc++.h>

using namespace std;
int n,A[52],L,B[52];
void roll()
{
    for (int i = 1; i <= n; i++)
    {
        B[i]++;
        B[i] %= L;
    }
}
int main()
{
    cin>>n>>L;
    for (int i = 1; i <= n; i++)
    {
        cin>>A[i];
    }
    for (int i = 1; i <= n; i++)
    {
        cin>>B[i];
    }
    bool w = false;
    for (int i = 1; i <= L*L && !w; i++)
    {
        roll();
        sort(B+1,B+n+1);
        bool f = true;
        for (int j = 1; j <= n && f; j++)
        {
            if (A[j] != B[j]) f = false;
        }
        if (f) w = true;
    }
    if (w) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

#include<bits/stdc++.h>
#define debug(x)  cout<<'>'<<#x<<" : "<<x<<endl;
using namespace std;

int arr[1000], b[10009];

int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int N, K;

    cin >> K >> N;

    for(int i = 0; i < K; i++){
        int a;
        cin >> a;
        arr[a] = arr[a+N] = 1;
    }

    for(int i = 0; i < K; i++){

        cin >> b[i];

    }

    int match = 0;
    for(int i = 0; i < N; i++){

        match = 0;
        for(int j = 0; j < N; j++){
            if(arr[i+j] and j != b[match]) break;
            else if(arr[i+j] and j == b[match]) match++;

        }

       if(match == K){
// 			debug(i);
        break;
       }
    }
    if(match == K) cout << "YES";
    else cout << "NO";

}

#include<bits/stdc++.h>
using namespace std;
vector<int> a,b;
int n,L,v[110];
int main()
{
	scanf("%d%d",&n,&L);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	v[n+1]=v[1]+L;
	for(int i=1;i<=n;i++)a.push_back(v[i+1]-v[i]);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	v[n+1]=v[1]+L;
	for(int i=1;i<=n;i++)b.push_back(v[i+1]-v[i]);
	for(int i=0;i<n;i++)
	{
		bool flag=1;
		for(int j=0;j<n;j++)
		{
			if(a[j]!=b[(i+j)%n])
			{
				flag=0;
				break;
			}
		}
		if(flag)
		{
			puts("YES");
			return 0;
		}
	}
	puts("NO");
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, l;
    scanf("%d %d", &n, &l);
    vector <int> papug;
    vector <int> camel;
    for(int i = 0; i < n;++i){
        int c;
        scanf("%d", &c);
        papug.push_back(c);
    }
    for(int i = 0; i < n;++i){
        int c;
        scanf("%d", &c);
        camel.push_back(c);
    }
    vector <int> papug_distance;
    vector <int> camel_distance;
    for(int i = 0; i < n-1; ++i){
        papug_distance.push_back(papug[i+1]-papug[i]);
    }
    papug_distance.push_back(l-papug[papug.size()-1]+papug[0]);
    for(int i = 0; i < n-1; ++i){
        camel_distance.push_back(camel[i+1]-camel[i]);
    }
    camel_distance.push_back(l-camel[camel.size()-1]+camel[0]);
    for(int i = 0; i < n; i++){
        camel_distance.push_back(camel_distance[i]);
    }
    for(int i = 0; i<papug_distance.size();i++){
        bool rnd = true;
        for(int j = 0; j<papug_distance.size(); j++){
                if(papug_distance[j]!=camel_distance[j+i]){
                    rnd = false;
                    break;
                }
        }
        if(rnd){
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const double eps = 1e-6;
const int INF = 2e9;
const LL LNF = 9e18;
const int mod = 1e9+7;
const int maxn = 100+10;

int n,L;
int a[maxn], b[maxn];
int ina[maxn], inb[maxn];

int main()
{
    cin>>n>>L;
    for(int i = 1; i<=n; i++)
        cin>>a[i];
    for(int i = 1; i<=n; i++)
        cin>>b[i];

    a[n+1] = L+a[1], b[n+1] = L+b[1];   //因为环，所以要求出尾到首的距离
    for(int i = 1; i<=n; i++)
    {
        ina[i] = a[i+1]-a[i];   //求出甲的间隔距离
        inb[i] = b[i+1]-b[i];   //求出乙的间隔距离
    }

    int B = 0;
    for(int k = 0; k<n; k++) //错开的幅度
    {
        int i;
        for(i = 1; i<=n; i++)   //甲间隔的下标
        {
            int j = (i+k)<=n?(i+k):(i+k)%n;    //乙间隔的下标，因为循环，所以要特判。
            if(ina[i]!=inb[j])
                break;
        }
        if(i==1+n)  //间隔距离完全匹配
        {
            B = 1;
            break;
        }
    }

    if(B)
        puts("YES");
    else
        puts("NO");
}

//
//  main.cpp
//  Codeforces Round #394 (Div. 2) - B. Dasha and friends
//
//  Created by S M HEMEL on 5/10/17.
//  Copyright © 2017 Eastern University. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
int n,m;
int a[100],b[100],c[100];
int main()
{
    scanf("%d%d", &n, &m);
    for(int i=0; i<n; i++)
        scanf("%d", &a[i]);
    for(int i=0; i<n; i++)
        scanf("%d", &b[i]);
    for(int i=0; i<m; i++)
    {
        for(int j=0; j<n; j++)
            c[j] = (b[j]+i)%m;
        sort(c,c+n);
        bool check = true;
        for(int j=0; j<n; j++)
            if (a[j] != c[j]) {
                check = false;
                break;
            }
        if(check)
            return 0 * puts("YES");
    }
    printf("NO\n");
    return 0;
}

#include <iostream>
using namespace std;
int main () {
    int n, l;
    cin >> n >> l;
    int a[n], b[n], a1[n], b1[n];
    for (int i = 0 ; i < n; ++i) {
        cin >> a[i];
        if (i)
            a1[i - 1] = a[i] - a[i - 1];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        if (i)
            b1[i - 1] = b[i] - b[i - 1];
    }
    a1[n - 1] = l - a[n - 1] + a[0];
    b1[n - 1] = l - b[n - 1] + b[0];
    bool k = false;
    for (int i = 0; i < n; ++i) {
            bool t = true;
        for (int j = 0 ; j< n; ++j) {
            if (a1[j] != b1[(j + i) % n]){
                t = false;
                break;
            }
        }

            if (t) {
                k = true;
                break;
            }
    }
    if (k || n == 1)
        cout << "YES";
    else
        cout << "NO";
return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    //freopen("in", "r", stdin);
    //freopen("out", "w", stdout);
    int b = 0;
    int l = 0;
    int pre = 0;
    int now = 0;

    scanf("%d %d", &b, &l);

    vector<int> v1;
    vector<int> v2;

    for (int i = 0; i < b; ++i) {
	scanf("%d", &now);
	v1.push_back(now - pre);
	pre = now;
    }

    v1[0] += l - now;
    pre = 0;

    for (int i = 0; i < b; ++i) {
	scanf("%d", &now);
	v2.push_back(now - pre);
	pre = now;
    }

    v2[0] += l - now;

    //for (int i = 0; i < b; ++i) printf("%d ", v1[i]);
    //printf("\n");
    //for (int i = 0; i < b; ++i) printf("%d ", v2[i]);

    for (int i = 0; i <= b; ++i) {
	rotate(v2.begin(), v2.begin() + 1, v2.end());
	if (v1 == v2) {
	    printf("YES\n");
	    return 0;
	}
    }
    printf("NO\n");

    return 0;
}

#include<iostream>
#include<algorithm>
using namespace std;
int n,L,i,a[51],b[51],c[51],d[51],s,j;
bool bo;
main()
{
      cin>>n>>L;
      for(i=0;i<n;i++)
         cin>>a[i];
      for(i=0;i<n;i++)
         cin>>b[i];

      for(i=0;i<n-1;i++){
         c[i]=a[i+1]-a[i];
         s+=c[i];
      }
      c[n-1]=L-s;
      s=0;
      for(i=0;i<n-1;i++){
         d[i]=b[i+1]-b[i];
         s+=d[i];
      }
      d[n-1]=L-s;

      for(i=0;i<n;i++){
         bo=true;
         for(j=0;j<n;j++){
            if(c[(i+j)%n]!=d[j]){
              bo=false;
              break;
            }
         }
         if(bo==true){
           cout<<"YES"<<endl;
           return 0;
         }
      }
      cout<<"NO"<<endl;
      //system("pause");
}

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(int argc, char const *argv[]) {\
//freopen("in", "r", stdin);
//freopen("out", "w", stdout);
  int n,l;
  cin>>n>>l;
  int a[n+1],b[n+1],f[n+1],s[n+1];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }

    for(int i=1;i<n;i++){
        f[i]=a[i]-a[i-1];
        s[i]=b[i]-b[i-1];
    }
    f[0]= l-a[n-1]+a[0];
    s[0]= l-b[n-1]+b[0];

    for(int i=0;i <= n;i++){
        int d = 0;
        int temp = s[0];

        for(int j=0;j<n-1;j++){
            s[j] = s[j+1];

        }
        s[n-1] = temp;

        for(int j=0;j<n;j++){
            if(s[j] == f[j]) d++;

        }
        if(d == n){
            cout<<"YES";
            return 0;
        }

    }

    cout<<"NO";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100],b[100];
int n,l;

bool check(int pos)
{
	int tmp=(b[pos]-a[0]+l)%l;
	for(int i=0;i<n;i++)
		if((a[i]+tmp)%l!=b[(pos+i)%n])
			return 0;
	return 1;
}
int main()
{
#ifndef ONLINE_JUDGE
    //freopen("b.in","r",stdin);
    //freopen("b.out","w",stdout);
#endif
	cin >> n >> l;
	for(int i=0;i<n;i++)
		cin >> a[i];
	for(int i=0;i<n;i++)
		cin >>b[i];
	for(int i=0;i<n;i++)
		if(check(i))
		{
			puts("YES");
			return 0;
		}
	puts("NO");
	return 0;
}

#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<set>
#include<vector>
using namespace std;
int main()
{
	long long a,b,c=0,i,j,k;
	long long pr[50],pr1[50];
	cin>>a>>b;
	j=b;
	for(i=0;i<a;i++)
	{
		cin>>pr[i];
	}
	for(i=0;i<a;i++)
	{
		cin>>pr1[i];

	}
	while(j>0)
	{c=0;
		for(i=0;i<a;i++)
	{
		 pr[i]=pr[i]-1;
		 if(pr[i]<0) pr[i]=pr[i]+b;

		 }
		sort(pr,pr+a);
		for(i=0;i<a;i++)
	{
		if(pr[i]==pr1[i]) c++;
		}

		if(c==a) {cout<<"YES";return 0;}
		j--;
	}
	cout<<"NO";
}

#include <bits/stdc++.h>
using namespace std;

typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define endt                        '\t'
#define ends                        ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
inline int input(){int n; cin >> n ; return n;}
ll pw(ll a , ll b)  { return (!b ? 1 : (b & 1 ? a * pw(a * a , b / 2) : pw(a * a , b / 2))); }

int main(){
    fast_io;

    int n, l;
    cin >> n >> l;

    int a[n + 1] , b[n + 1];
    for(int i = 0 ; i < n ; i++)    cin >> a[i];
    for(int i = 0 ; i < n ; i++)    cin >> b[i];
    a[n] = a[0] + l , b[n] = b[0] + l;

    vector<int> vec(n) , sec(n);
    for(int i = 0 ; i < n ; i++){
        vec[i] = abs(a[i] -a[(i + 1)]);
        sec[i] = abs(b[i] - b[(i + 1)]);
    }

    for(int i = 0 ; i < n ; i++){
        rotate(vec.begin() , vec.begin() + 1 , vec.end());
        int ok = 1;
        for(int j = 0 ; j < n - 1 ; j++){
            if(vec[j] != sec[j]){
                ok = 0;
                break;
            }
        }
        if(ok)  return cout << "YES" << endl , 0;
    }
    cout << "NO" << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);
	int n, L;
	cin >> n >> L;
	vector<int>a;
	int st1;
	int prev = -1;
	for(int i = 0; i < n; i++){
		int val;
		cin >> val;
		if(i > 0){
			assert(prev != -1);
			a.push_back(val - prev);
		}
		prev = val;
		if(i == 0)
			st1 = val;
	}
	a.push_back(L - prev + st1);
	prev = -1;
	vector<int>b;
	for(int i = 0; i < n; i++){
		int val;
		cin >> val;
		if(i > 0){
			assert(prev != -1);
			b.push_back(val - prev);
		}
		if(i == 0)
			st1 = val;
		prev = val;
	}
	b.push_back(L - prev + st1);
	assert( (int)a.size() == (int)b.size());
	for(int i = 0; i < (int)a.size();i++){
		bool good = true;
		rotate(a.begin(), a.begin() + 1, a.end());
		for(int j = 0; j < (int)b.size(); j++)
		{
			if(a[j] != b[j])
				good = false;
		}
		if(good == true){
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
int main(){
	ll n, l, a[100045], e, i, j;
	map < ll , ll > mp;
	cin >> n >> l;
    for( i = 0; i < n; i ++ ){
        cin >> a[i];
    }
    for( i = 0; i < n; i ++ ){
        cin >> e;
        mp[ e ] = 1;
    }
    for(i = 0; i < l; i ++){
        ll flag = true;
        for( j = 0; j < n; j ++ ){
            if( mp[ (a[j] + i) % l ] == 0 )
                flag = false;
        }
        if( flag == true ){
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}

#include <iostream>

using namespace std;

int main()
{

	int n, l, i;

	int a[210];
	int b[210];

	cin >> n >> l;
	bool ans = true;

	for (i = 0; i < n; i++) cin >> a[i];
	for (i = 0; i < n; i++) cin >> b[i];

	a[n] = a[0] + l;
	b[n] = b[0] + l;

	for (i = 0; i < n; i++) a[i + n] = a[i] + l;
	for (i = 0; i < n; i++) b[i + n] = b[i] + l;

	for (int sdv = 0; sdv < n; sdv++)
	{
		bool ans = true;
		for (i = 0; i < n; i++)
		{
			ans = ans & ((a[i + 1] - a[i]) == (b[i + sdv + 1] - b[i + sdv]));
		}
		if (ans == true)
		{
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main (){
	int n,l;
	cin>>n>>l;
	vector<int> a;
	vector<int> b;
	for (int i=0;i<n;i++){
		int t1;
		cin>>t1;
		a.push_back(t1);
	}
	for (int i=0;i<n;i++){
		int t2;
		cin>>t2;
		b.push_back(t2);
	}
	vector<int> m1;
	vector<int> m2;
	for (int i=1;i<n;i++){
		m1.push_back(a[i]-a[i-1]);
	}
	m1.push_back(l-a[n-1]+a[0]);
	for (int i=1;i<n;i++){
		m2.push_back(b[i]-b[i-1]);
	}
	m2.push_back(l-b[n-1]+b[0]);
	/*multiset<int>::iterator it1=m1.begin();
	multiset<int>::iterator it2=m2.begin();
	while(it1!=m1.end() && it2!=m2.end()){
		if (*it1!=*it2){
			cout<<"NO"<<endl;
			return 0;
		}
		it1++;
		it2++;
	}
	cout<<"YES"<<endl;*/
	if (m1.size()==0){
		cout<<"YES"<<endl;
		return 0;
	}
	vector<int>::iterator it2=find(m2.begin(),m2.end(),m1[0]);
	if (it2==m2.end())
	{
		cout<<"NO"<<endl;
		return 0;
	}
	int ind=it2-m2.begin();
	//cout<<"ind"<<ind<<endl;
	int i=(ind+1);
	int j=1;
	while (i!=ind && j<n){
		//cout<<" j "<<j<<m1[j]<<endl;
		//cout<<" i "<<i<<m2[i]<<endl;
		if (m1[j]!=m2[i])
		{
			cout<<"NO"<<endl;
			return 0;
		}
		i=(i+1)%n;
		j=j++;
	}
	cout<<"YES"<<endl;
	return 0;
}

// Abhay Singh Bhadoria ( _Asb_ ) //
#include<bits/stdc++.h>
using namespace std;
const int inf = 2147483647;
const int M = 1e9 + 7;
const int N = 50 + 5;
int kefa[N],sasha[N];
set<int> ke,sa;
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int n,l;
    cin>>n>>l;
    for(int i=0;i<n;++i)cin>>kefa[i];
    for(int i=1;i<n;++i){
        ke.insert(kefa[i]-kefa[i-1]);
    }
    ke.insert(kefa[0]-kefa[n-1]+l);
    for(int i=0;i<n;++i)cin>>sasha[i];

    for(int i=1;i<n;++i){
        sa.insert(sasha[i]-sasha[i-1]);
    }
    sa.insert(sasha[0]-sasha[n-1]+l);
    for(set<int> ::iterator it1=ke.begin(),it2=sa.begin();it1!=ke.end();++it1,++it2){
            //cout<<*it1<<' '<<*it2<<endl;
        if(*it1!=*it2){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n, L;
	cin >> n >> L;
	vector<int>a;
	int prev = -1;
	for(int i = 0; i < n; i++){
		int val;
		cin >> val;
		if(i > 1 || (n == 2 && i > 0)){
			assert(prev != -1);
			a.push_back(prev - val);
		}
		prev = val;
	}
	prev = -1;
	vector<int>b;
	for(int i = 0; i < n; i++){
		int val;
		cin >> val;
		if(i > 1 || (n == 2 && i > 0)){
			assert(prev != -1);
			b.push_back(prev - val);
		}
		prev = val;
	}
	assert( (int)a.size() == (int)b.size());
	for(int i = 0; i < (int)a.size();i++){
		if(a[i] != b[i]){
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
}

#include<iostream>
const int N=50;
int main()
{
	using namespace std;
	int n,L, dis;
	cin>>n>>L;

     dis=L/2;

	int b[50]={0}, tem=0;
	int chaA[N]={0}, chaB[N]={0};

	for (int i=0; i<n; ++i)
	{
		cin>>b[i];
	}
	for (int i=0; i<n; ++i)
	{
		for(int j=i+1; j<n; j++)
		{
			if(b[j]-b[i]<=dis)
				chaA[b[j]-b[i]]++;
			else
			{
				tem=L-(b[j]-b[i]);
				chaA[tem]++;
			}
		}
	}

	for (int i=0; i<n; ++i)
	{
		cin>>b[i];
	}
	for (int i=0; i<n; ++i)
	{
		for(int j=i+1; j<n; j++)
		{
			if(b[j]-b[i]<=dis)
				chaB[b[j]-b[i]]++;
			else
			{
				tem=L-(b[j]-b[i]);
				chaB[tem]++;
			}
		}
	}
	int flag=0;
	for(int i=0; i<=dis; ++i)
	{
		if(chaA[i]!=chaB[i])
		{ flag=1; break;}
	}
	if(flag) cout<<"NO"<<endl;
	else     cout<<"YES"<<endl;

	return 0;
}

/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define gcd(a,b) __gcd(a,b)
#define TEST int t;cin>>t;while(t--)
const long long int p = 1e9+7;
typedef unsigned  long long int ll;
#define INF 1000000000
#define ss second
#define ff first
using namespace std;
static int hash1[200],hash2[200];
int main()
{
	int a,b;
	cin >> a >> b;
	int arc1[1000],arc2[1000];
	for(int i = 0 ; i < a; i++)
	cin >> arc1[i];
	for(int i = 0; i < a; i++)
	cin >> arc2[i];
	for(int i = 1;i < a; i++)
	{
		hash1[arc1[i]-arc1[i-1]]++;
		hash2[arc2[i]-arc2[i-1]]++;

	}
	hash1[b-arc1[a-1]+arc1[0]]++;
	hash2[b-arc2[a-1]+arc2[0]]++;
	int i ;
	for(i = 0; i < 200; i++)
		if(hash1[i]!=hash2[i])
		break;
	if(i==200)
		cout<<"YES";
	else
		cout<<"NO";
	// your code goes here
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	//freopen("a.in", "r", stdin);
	int bar, len, fir[10000] = {}, sec[10000] = {};
	int A[100000] = {}, B[100000] = {};
	cin >> bar >> len;
	for(int i = 0; i < bar; i++)
		cin >> fir[i];
	for(int i = 0; i < bar; i++)
		cin >> sec[i];
	int cntA = 0;
	for(int i = 0; i < bar; i++)
	{
		for(int j = i+1; j < bar; j++)
		{
			A[cntA++] = fir[j] - fir[i];
			A[cntA++] = (len-fir[j]) + fir[i];
		}
	}
	int cntB = 0;
	for(int i = 0; i < bar; i++)
	{
		for(int j = i+1; j < bar; j++)
		{
			B[cntB++] = sec[j] - sec[i];
			B[cntB++] = (len-sec[j]) + sec[i];
		}
	}
	sort(A+0, A+cntA);
	reverse(A+0, A+cntA);
	sort(B+0, B+cntB);
	reverse(B+0, B+cntB);
	for(int i = 0; i < cntA; i++)
		A[0] += A[i];
	for(int i = 0; i < cntB; i++)
		B[0] += B[i];
	for(int i = 0; i < cntA; i++)
	{
		if(A[i] != B[i])
			{
				cout << "NO";
				return 0;
			}
	}
	return 0;
}

//Pratyush Prakash

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
#include <set>

#include <map>
#include <queue>
#include <list>
#include <math.h>

#define ll long long int
#define maxN 200
#define maxVal 1e8
#define minVal -1e8
#define mod 1e9+7
#define mp make_pair
#define pb push_back
#define gcd(a,b) __gcd(a,b)

using namespace std;
int a[105],b[105],c[105],n,l;
bool check(int in)
{
    int d,i,j;
    d = a[0]-b[in];
    for(i=0;i<n;i++)
    {
        c[i]=b[i]+d;
        if(c[i]<0)
            c[i]+=l;
       // cout << c[i] << " ";
    }
    //cout << endl;
    for(i=0;i<n;i++)
        {
            if(a[i]!=c[in%n])
                return false;
            in=(in+1)%l;
        }
}
int main()
{
    int i,j,k,f=-1;
    ios::sync_with_stdio(false);
    cin >> n >> l;
    for(i=0;i<n;i++)
        cin >>a[i];
    for(i=0;i<n;i++)
        cin >> b[i];
    for(i=0;i<n;i++)
    {
        if(check(i)==true)
        {
            f=0;
            break;
        }
    }
    if(f==0)
        cout <<"YES"<<endl;
    else
        cout << "NO" << endl;
}

#include <bits/stdc++.h>
using namespace std;

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fp(i,s,t) for(int i = s; i >= t; -- i)
#define go(i,s) for(int i = head[s]; i; i = e[i].next)
const int maxn = 100050;
const int maxm = 1005;

int n, m, a[maxn], b[maxn], c[maxn], d[maxn];

int f(int x){return x%n==0?1:x;}

int main()
{
	cin >> n >> m;
	fo(i,1,n) cin >> a[i], c[i] = a[i]-a[i-1];
	fo(i,1,n) cin >> b[i], d[i] = b[i]-b[i-1];
	c[1] = m - a[n] + c[1];
	d[1] = m - b[n] + d[1];
	bool ok;
	fo(i,1,n) fo(j,1,n) if(c[i] == d[j])
	{
		ok = false;
		fo(k,1,n) if(c[f(i+k-1)]!=d[f(j+k-1)]) {ok = true; break;}
		if(ok) {cout << "YES"; return 0;}
	}
	cout << "NO";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,l;
    cin>>n>>l;
    unordered_map<int, int> hashtable;
   int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(i!=0 && i!=n-1)
        {
            hashtable.emplace(arr[i]-arr[i-1],0);
        }
    }
    hashtable.emplace(arr[0]+l-arr[n-1],0);

    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        if(i!=0 && i!=n-1)
        {
            auto search = hashtable.find(arr[i]-arr[i-1]);
            if(search == hashtable.end())
            {
                cout<<"NO";
                return 0;
            }
        }

    }
    auto search = hashtable.find(arr[0]+l-arr[n-1]);
     if(search == hashtable.end())
            {
                cout<<"NO";
                return 0;
            }
    cout<<"YES";

return 0;
}

#include <bits/stdc++.h>

using namespace std;

bool same(vector<int> v1,vector<int> v2)
{
    int cnt=0;

    while(v1!=v2 && cnt<=v1.size())
    {
        int temp=v2[v2.size()-1];
        v2.pop_back();
        v2.insert(v2.begin(),temp);
        cnt++;
    } //n*n

    if(v1!=v2)
        return false;
    else
        return true;
}

int main()
{
    int n,l;
    cin>>n>>l;

    vector<int> a,b;

    int firsta,firstb;

    cin>>firsta;
    int num1,num2;
    num1=firsta;

    for(int i=1;i<n;i++)
    {
        cin>>num2;
        a.push_back(abs(num2-num1));
        num1=num2;
    } //n
    a.push_back(firsta+(l-num2));

    cin>>firstb;
    num1=firstb;

    for(int i=1;i<n;i++)
    {
        cin>>num2;
        b.push_back(abs(num2-num1));
        num1=num2;
    } //n
    b.push_back(firstb+(l-num2));

    if(same(a,b))
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}

// Devarshi

#include<bits/stdc++.h>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn=1000001;

int main(){

int n,s;
cin>>n>>s;

int a[n],b[n];

forn(i,n) cin>>a[i];
forn(i,n) cin>>b[i];

map<int,int> mm;

mm[a[n-1]-a[0]]=1;
mm[s-(a[n-1]-a[0])]=1;

fore(i,1,n-1){
mm[a[i]-a[i-1]]=1;
mm[s-(a[i]-a[i-1])]=1;
}
fore(i,1,n-1){
if(mm[b[i]-b[i-1]]!=1){
    cout<<"NO";
    return 0;
}
}
if(mm[b[n-1]-b[0]]!=1){
    cout<<"NO";
}
else
cout<<"YES";
return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l,c=0,u;
	cin>>n>>l;
	int a[n],b[n], o[n],p[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n;i++)
	cin>>b[i];
	for(int i=0;i<n-1;i++)
	o[i]=a[i+1]-a[i];
	o[n-1]=l-a[n-1]+a[0];
	for(int i=0;i<n-1;i++)
	p[i]=b[i+1]-b[i];
	p[n-1]=l-b[n-1]+b[0];
    for(int i=0;i<n;i++)
    {
    	int j=0;
    	while(o[i]!=p[j])
    	j++;
    	u=i;
    	while(o[u%n]==p[j%n]&&c<n)
    	{
    		u++;
    		j++;
    		c++;
		}
		if(c==n)
		break;
	}
	if(c==n)
	cout<<"YES";
	else
	cout<<"NO";
}

#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lld long long int
#define ll long double
#define p(x) cout<<x<<endl
#define vect(x,n) vector<lld>x(n,0)
#define sorta(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.begin(),v.end(),greater<lld>())
#define all(v) v.begin(),v.end()
#define matrix(x,n,m) vector<vector<lld>>x(n,vector<lld>(m,0))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define lb lower_bound
#define F first
#define S second
#define pb push_back
#define mkp make_pair
const lld mod=1e9+7;
lld pow(lld x, lld y) { lld res = 1; while (y >(lld)0) { if (y &(lld)1) res = ((res) * (x)); y = y >>(lld)1; x = ((x) * (x)); } return res; }

void solve()
{
    lld i,j,k,ans,a,b,c,mx,mn,t,n,m,x,temp,p,q,y,z,l,r,g,flg,sum,d,cnt,sumf,diff,odd,even;
    cin>>n>>a;
    vector<lld>arr1(n),arr2(n),sasha,kefa;
    for(i=0;i<n;i++)
        cin>>arr1[i];
    for(i=0;i<n;i++)
        cin>>arr2[i];
    sorta(arr1);
    sorta(arr2);
    for(i=1;i<n;i++)
        sasha.pb(arr1[i]-arr1[i-1]);
    sasha.pb(arr1[0]+a-arr1[n-1]);
    for(i=1;i<n;i++)
        kefa.pb(arr2[i]-arr2[i-1]);
    kefa.pb(arr2[0]+a-arr2[n-1]);
    sorta(sasha);
    sorta(kefa);
    if(sasha==kefa)
        p("YES");
    else
        p("NO");
    return;
}

int main()
{
    fast;
    lld t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

#include <iostream>
#include <cstdio>
using namespace std;
int a[55], b[55], aa[55], bb[55];

int main(void)
{
    int n, L;
    scanf("%d %d", &n, &L);
    for(int i = 0; i < n; i++) scanf("%d", a + i);
    for(int i = 0; i < n; i++) scanf("%d", b + i);
    for(int i = 0; i < n - 1; i++) aa[i] = a[i+1] - a[i], bb[i] = b[i+1] - b[i];
    aa[n-1] = L - a[n-1] + a[0];
    bb[n-1] = L - b[n-1] + b[0];
    for(int i = 0; i < n; i++)
    {
        int ok = 1;
        for(int j = 0; j < n; j++)
            if(aa[(i+j)%n] != bb[j])
            {
              //  cout<<i<<" "<<j<<endl;
                ok = 0;
        if(ok==1) return puts("YES");}
    }
    puts("NO");
    return 0;
}

#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

int main(){
	int n, L, k[50] = { 0 }, s[50] = {0}, t, tt;
	bool ok = false;

	cin >> n >> L;

	cin >> k[0];
	tt = k[0];
	for (int i = 1; i < n; i++){
		cin >> t;
		k[i] = t - tt;
		tt = t;
	}
	k[0] += L - t;

	cin >> s[0];
	tt = s[0];
	for (int i = 1; i < n; i++){
		cin >> t;
		s[i] = t - tt;
		tt = t;
	}
	s[0] += L - t;

	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (k[i] == s[j]){
				ok = true;
				for (int z = 0; z < n; z++){
					if (k[(i + z) % n] != s[(j + z) % n]){
						cout << "K: " << k[(i + z) % n] << " ki: " << (i + z) % n << endl;
						cout << "S: " << s[(j + z) % n] << " si: " << (j + z) % n << endl;
						ok = false;
					}
				}
				if (ok){
					cout << "YES ";
					//system("PAUSE");
					return 0;
				}
			}
		}
	}
	cout << "NO";

	//system("PAUSE");
	return 0;
}

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Ahmad Hamadneh
 */

#include <bits/stdc++.h>

using namespace std;

class BDashaAndFriends {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, l;
        in >> n >> l;
        vector<int> v(n);
        for (int i = 0; i < n; i++) {
            in >> v[i];
        }
        int x;
        for (int i = 0; i < n; i++) {
            in >> x;
            v[i] = abs(v[i] - x);
        }
        for (int i = 1; i < n; i++) {
            if (v[i] - v[i - 1] != 0) {
                out << "NO\n";
                return;
            }
        }
        out << "YES\n";
    }
};

int main() {
    BDashaAndFriends solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
int a[1000],b[1000];
vector<int> v1,v2;
int main()
{
    int n,l;
    scanf("%d%d",&n,&l);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=0; i<n; i++)
    {
        scanf("%d",&b[i]);
    }
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(i==j)
                continue;
            //if(i==0&&j==n-1||j==0)
            //{
              //  v1.push_back(abs(l-a[j]+a[i]));
                //v2.push_back(abs(l-b[j]+b[i]));
                //continue;
            //}
            int d=abs(a[i]-a[j]);
            int d1=abs(b[i]-b[j]);
            v1.push_back(min(d,abs(l-d)));
            v2.push_back(min(d1,abs(l-d1)));
        }
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    for(int i=0; i<n; i++)
    {
        if(v1[i]!=v2[i])
        {
            printf("NO");
            return 0;
        }
    }
    printf("YES");
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int i , j , n , l , x , y;
    int a[500],b[500],difa[500],difb[500];
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));
    map<int,int> s;
    scanf("%d %d",&n,&l);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    for(i=0;i<n;i++)scanf("%d",&b[i]);

     difa[0]=l-a[n-1]+a[0];
     difb[0]=l-b[n-1]+b[0];
     s[difa[0]]++;
     s[difb[0]]--;
    for(i=1;i<n;i++){
        difa[i]=a[i]-a[i-1];
        difb[i]=b[i]-b[i-1];
        s[difa[i]]++;
        s[difb[i]]--;
    }

    for(std::map<int,int>::iterator it=s.begin(); it!=s.end(); ++it){
        if(it->second!=0){cout<<"NO"<<endl; return 0;}
    }

    cout<<"YES"<<endl;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

inline void in(vector <int>& v, int n)
{
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
}

int main()
{
	int n, l;
	cin >> n >> l;
	vector <int> a(n, 0), b(n, 0), da(n, 0), db(n, 0);
	in(a, n);
	in(b, n);
	for (int i = 1; i < n; i++)
	{
		da[i] = a[i] - a[i - 1];
		db[i] = b[i] - b[i - 1];
	}
	for (int i = 0; i < n; i++)
	{
		bool d = true;
		int dst = da[0] - db[0];
		for (int j = 0; j < n; j++)
		{
			if (da[i] - db[i] != dst)
			{
				d = false;
				break;
			}
		}
		if (d)
		{
			cout << "YES";
			return 0;
		}
		vector <int> c;
		for (int i = 1; i < n; i++)
		{
			c.push_back(da[i]);
		}
		c.push_back(da[0]);
		da = c;
		c.clear();
	}
	cout << "NO";
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int n,L;
    int a[55],b[55];

    cin >> n >> L;

    for(int i=0; i<n; i++)
        cin >> a[i];

    for(int i=0; i<n; i++)
        cin >> b[i];

    bool exist=1;

    /*   for(int i=1;i<n;i++)
       if(a[i]-a[i-1]!=b[i]-b[i-1]){
               exist=0;
               break;
       }
    */
    if(a[0]>=b[0])
    {
        int k=a[0]-b[0];
        for(int i=0; i<n; i++)
        {
            b[i]+=k;

        }

        if(b[n-1]>=L)
            for(int i=1; i<n; i++)
            {
                b[i]-=(2*k);
            }
    }
    else
    {

        int k=b[0]-a[0];
        for(int i=0; i<n; i++)
        {
            a[i]+=k;

        }

        if(a[n-1]>=L)
            for(int i=1; i<n; i++)
            {
                a[i]-=(2*k);
            }

    }

    for(int i=0; i<n; i++)
        if(a[i]!=b[i])
        {
            exist=0;
            break;
        }

    if(exist)
        cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

#include<iostream>
#include<cmath>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
	int a[51], b[51];
	int aa[51], bb[51];
	int n,m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	for (int i = 1; i < n; i++)
	{
		aa[i] = a[i] - a[i - 1];
		bb[i] = b[i] - a[i - 1];
	}
	aa[0] = a[0] + m - a[n - 1];
	bb[0] = b[0] + m - b[n - 1];
	int flag = 0;
	for (int i = 0; i < n; i++)
	{
		int j;
		for (j = 0; j < n; j++)
			if (aa[i] != bb[(i + j) % n])
				break;
		if (j == n)
		{
			flag = 1;
			break;
		}
	}
	if (flag)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

int main()
{
    int l, n;

    cin >> n >> l;

    int k[n];
    int s[n];

    bool can = true;

    for (int i = 0; i < n; i++) cin >> k[i];
    for (int i = 0; i < n; i++) cin >> s[i];

    vector <int> kr(n);
    vector <int> sr(n);

    for (int i = 1; i < n; i++) kr[i] = k[i] - k[i - 1];
    kr[0] = l - k[n- 1] + k[0];

    for (int i = 1; i < n; i++) sr[i] = s[i] - s[i - 1];
    sr[0] = l - s[n- 1] + s[0];

    sort(kr.begin(), kr.end());
    sort(sr.begin(), sr.end());

    for (int i = 0; i < n; i++){
        if (kr[i] != sr[i]){
            can = false;
            break;
        }
    }

    if (n == 1) can = true;

    if (can) cout << "YES";
        else cout << "NO";

   /* for (int i = 0; i < n; i++) cout <<  kr[i] << " ";cout << endl;
    for (int i = 0; i < n; i++) cout <<  sr[i] << " ";*/

    return 0;
}

#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int n,l;
int main(){_
	cin >> n >> l;
	priority_queue < int > q1,q2;int tmp1,tmp2,first;
	for(int x = 0; x < n; x++){
		if(x == 0){
			cin >> tmp1;
			first = tmp1;
		}
		else{
			cin >> tmp2;
			q1.push(tmp2 - tmp1);
			tmp1 = tmp2;
		}
	}
	q1.push(((l - 1) - tmp2) + (first - 0) + 1);
	for(int x = 0; x < n; x++){
		if(x == 0){
			cin >> tmp1;
			first = tmp1;
		}
		else{
			cin >> tmp2;
			q2.push(tmp2 - tmp1);
			tmp1 = tmp2;
		}
	}
	q2.push(((l - 1) - tmp1) + (first - 0) + 1);
	bool sama = true;
	while(q1.size() != 0){
		//cout << q1.top() << " " << q2.top() << endl;
		if(q1.top() != q2.top())
			sama = false;
		q1.pop();
		q2.pop();
	}
	if(sama)
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}

#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <iomanip>
#include <queue>

#define f first
#define s second
#define ll long long

using namespace std;

int sv[5000010];

void sieve()
{
    for(int i=2;i<=sqrt(5000010);i++)
    {
        if(sv[i]==0)
        {
            sv[i]=i;
            for(int j=i*i;j<5000010;j+=i)
            {
                sv[j]=i;
            }
        }
    }
}

double pow_(double a,ll b)
{
    if(b==0)
    {
        return 1;
    }
    if(b%2==1)
    {
        return pow_(a,b-1)*a;
    }
    else
    {
        double x=pow_(a,b/2);
        return x*x;
    }
}

int bin_s(vector< pair<int,int> >& v, int x)
{
    int l=0,r=v.size()-1;
    while(l!=r-1)
    {
        int m=(l+r)/2;
        if(v[m].f>x)
        {
            r=m;
        }
        else
        {
            l=m;
        }
    }
    if(v[r].f==x)
    {
        return r;
    }
    else if(v[l].f==x)
    {
        return l;
    }
    else
    {
        return -1;
    }
}

int gcd(int a,int b)
{
    if(a<b)
        swap(a,b);
    return (b==0? a:gcd(a%b,b));
}

int main()
{
    ios_base::sync_with_stdio(false);
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    srand(time(NULL));
    int n,l;
    cin>>n>>l;
    vector<int> a(n),b(n),d(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(i>0)
        {
            d[i]=a[i]-a[i-1];
        }
    }
    d[0]=l-a[n-1]+a[0];
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        bool t=true;
        for(int j=i;j<n;j++)
        {
            int x;
            if(j==0)
            {
                x=8-b[n-1]+b[0];
            }
            else
            {
                x=b[j]-b[j-1];
            }
            if(x!=d[i])
            {
                t=false;
                break;
            }
        }
        if(t)
        {
            cout<<"YES";
            return 0;
        }
    }
    cout<<"NO";
    return 0;
}

// B.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, l;
	cin >> n >> l;
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	int add = abs(a[0] - b[0]);

	if (a[n - 1] + add == b[n - 1] || a[n - 1] == b[n - 1] + add) cout << "YES";
	else cout << "NO";
    return 0;
}

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
#define kill freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define Boost() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD1 1000000007
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
#define oo 1000000007
ll lcm(ll a,ll b){
    return(a*b)/gcd(a,b);
}

void solve(){
   ll n,l;
   cin>>n>>l;
   ll a[n*2LL],b[n+1];
   fo(i,n){cin>>a[i];a[i+n]=a[i]+l;}
   fo(i,n)cin>>b[i];
   b[n]=b[0]+l;
   map<ll,ll> m1,m2;
   fo(i,n){
       m2[b[i+1]-b[i]]++;
   }
   for(ll k=0;k<n;k++){
       m1.clear();
       ll f=0;
       fo(i,n){
           m1[a[i+k+1]-a[i+k]]++;
       }
       go(m1,it){
       if(m2[it->fi]!=it->se){
           f=1;break;
       }
       }
       go(m2,it){
           if(m1[it->fi]!=it->se){
               f=1;break;
           }
       }
       if(!f){
           cout<<"YES";
           return;
       }
   }
   cout<<"NO";
}

int main(){
    Boost();
    #ifndef ONLINE_JUDGE
    kill
    #endif
    ll T = 1;
   // cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define ft first
#define sd second
#define all(a) a.begin(),a.end()
#define bitcnt(x) __builtin_popcountll(x)
#define inp(x) scanf("%lld",&x)
#define out(x) printf("%lld\n",x)
#define nl printf("\n")
#define tc int t;scanf("%d",&t);while (t-->0)
#define debug(x) cout<<"### x is: "<<x<<"###"<<endl
#define MOD 10000000019
#define MAXN 500005
#define ninf -1000000000
#define pinf 1000000000
//typedef unsigned long long int uint64;
typedef long long ll;
typedef vector<pair<ll,ll> > vecpair;

int main()
{
	ll n,i,j,l;

	inp(n);
	inp(l);

	ll a[n+1],b[n+1],c[n],d[n];

	for(i=0;i<n;i++)
	{
		inp(a[i]);
	}
	for(i=0;i<n;i++)
	{
		inp(b[i]);
	}

	for(i=0;i<n-1;i++)
	{
		c[i]=a[i+1]-a[i];
		if(c[i]<0)
		c[i]+=l;

		d[i]=b[i+1]-b[i];
		if(d[i]<0)
		c[i]+=l;
	}

	c[i]=a[0]-a[n-1];
	if(c[i]<0)
	c[i]+=l;

	d[i]=b[0]-b[n-1];
	if(d[i]<0)
	d[i]+=l;

	sort(c,c+n);
	sort(d,d+n);

	ll f=0;

	for(i=0;i<n;i++)
	{
		if(c[i]!=d[i])
		{
			f=1;
			break;
		}
	}

	if(f)
	cout<<"NO";
	else
	cout<<"YES";

	return  0;
}

//
//  main.cpp
//  CF #394 B
//
//  Created by 赵奕 on 17/1/21.
//  Copyright © 2017年 赵奕. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define N 1010
#define rep(i,a,b) for (int i=(a);i<=(b);++i)
#define rep2(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
int tot,n,m,ans,p[N],a[N],b[N],x[N],y[N];
string s;
bool find(int a[],int b[])
{
    int i,j,k;
    rep (i,1,n-1)
    if (b[i]==a[1])
    {
        j = 1;
        while (i+j-1<n-1&&b[i+j-1]==a[j])
            j++;
        if (i+j-1==n-1)
        {
            //k = 1;
            //while (j+k+1<n-1&&a[j+k+1]==b[k])
            //    k++;
            //if (j+k+1==n-1)
            //    return true;
            bool t = true;
            for (k = 1,j = j+2; j <= n-1; ++k,++j)
            if (a[j]!=b[k])
            {
                t = false;
                break;
            }
            if (t)
                return true;
        }
    }
    return false;
}
int main(int argc, const char * argv[])
{
    int i,j,k,ans;
    cin >> n >> m;
    rep (i,1,n){
        scanf("%d",&a[i]);
        if (i > 1)
        {
            x[i-1] = a[i]-a[i-1];
        }
    }
    rep (i,1,n){
        scanf("%d",&b[i]);
        if (i > 1)
        {
            y[i-1] = b[i]-b[i-1];
        }
    }
    if (n<=2)
    {
        puts("YES");
        return 0;
    }
    if (!find(x,y)&&!find(y,x))
    {
        puts("NO");
        return 0;
    }
    puts("YES");
    return 0;
}

#include <bits/stdc++.h>

#define maxn 100000008
#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main(int argc, char *argv[])
{
	int n, l;
	scanf("%d %d", &n, &l);
	vector<int> a;
	vector<int> b;
	int x[n];
	int y[n];
	scanf("%d", &x[0]);
	for (int i = 1; i < n; ++i) {
		scanf("%d", &x[i]);
		a.pp(x[i] - x[i-1]);
	}
	a.pp(l - x[n-1] + x[0]);
	scanf("%d", &y[0]);
	for (int i = 1; i < n; ++i) {
		scanf("%d", &y[i]);
		b.pp(y[i] - y[i-1]);
	}
	b.pp(l - y[n-1] + y[0]);

	if(n == 1){
		puts("YES");
		return 0;
	}

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int count = 0;
	for (int i = 0; i < a.size(); ++i) {
		if(a[i] != b[i]){
			count++;
		}
	}
	puts(count < 2 ? "YES" : "NO");
	return 0;
}

//CODE OF:-**HARRYoo7**//
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a)>=(b)?a:b
#define min(a,b) (a)<=(b)?a:b
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define first f;
#define second s;
main()
{
	int n,l;
	cin>>n>>l;
	int a[n],b[n],c=0;
	vector<int> v,u,v1,u1;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<n-1;i++)
	{
		v.push_back(a[i+1]-a[i]);
	}
	v.push_back(l-a[n-1]+a[0]);
		for(int i=0;i<n-1;i++)
	{
		v.push_back(a[i+1]-a[i]);
	}
	v.push_back(l-a[n-1]+a[0]);
	for(int i=0;i<n;i++)
	{
		cin>>b[i];
	}
	for(int i=0;i<n-1;i++)
	{
		u.push_back(b[i+1]-b[i]);
	}
	u.push_back(l-b[n-1]+b[0]);
	int k=0,j;
		for(j=0;j<v.size();j++)
		{k=0;
			if(v[j]==u[k])
			{
				k++;c++;
				for(int i=j+1;i<v.size();i++)
				{
					if(v[i]==u[k])
					{
						c++;
						k++;
					}
					else
					{
						c=0;
						break;
					}
					if(c==n)
					{
						cout<<"YES";
						break;
					}
				}
			}
			if(c==n)
			break;
		}
		if(j==2*n)
		cout<<"NO";
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    cin>>n>>l;
    int a[n],b[n],aaa[n],bbb[n],aa[n],bb[n];
    for (int i=0;i<n;i++)
        cin>>a[i];
    for (int i=0;i<n;i++)
        cin>>b[i];
    for (int i=0;i<n;i++)
    {
        if (!i)
        {
            aa[0]=l-a[n-1]+a[0];
            bb[0]=l-b[n-1]+b[0];
            continue;
        }
        aa[i]=a[i]-a[i-1];
        bb[i]=b[i]-b[i-1];
    }
    memcpy(aaa,aa,sizeof(aa));
    memcpy(bbb,bb,sizeof(bb));
    sort(aaa,aaa+n);
    sort(bbb,bbb+n);
    int p=1;
    for (int i=0;i<n;i++)
        if (aaa[i]!=bbb[i])
            p=0;
    if (p)
    {
        long long ans1=0,ans2=0;
        for (int i=0;i<n;i++)
        {
            if (aa[i]%2)
            {
                if (!i)
                    ans1+=aa[n-1];
                else
                    ans1+=aa[i-1];
            }
            else
            {
                if (i==n-1)
                    ans1+=aa[0];
                else
                    ans1+=aa[i+1];
            }
            if (bb[i]%2)
            {
                if (!i)
                    ans2+=bb[n-1];
                else
                    ans2+=bb[i-1];
            }
            else
            {
                if (i==n-1)
                    ans2+=bb[0];
                else
                    ans2+=bb[i+1];
            }
        }
        if (ans1==ans2)
            cout<<"YES";
        else
            cout<<"NO";
    }
    else
        cout<<"NO";
}

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<functional>
#include<bits/stdc++.h>
using  namespace std;
typedef long long ll;
//#define pd(x) printf("%d\n",x)
//#define plld(x) printf("%lld\n",x)
//#define pI64d(x) printf("%I64d\n",x)
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
const int INF=1e9;
const int MOD=1e9+7;
const int N=1e3+2;
const double eps=1e-4;
const double PI=acos(-1.0);
int a[N],b[N],s1[N],s2[N];
char s[N];
int main()
{
    int n,l;
    while(~scanf("%d%d",&n,&l))
    {
        memset(s1,0,sizeof(s1));
        memset(s2,0,sizeof(s2));
        for(int i=1; i<=n; i++) scanf("%d",&a[i]);
        for(int i=1; i<=n; i++) scanf("%d",&b[i]);
        for(int i=2; i<=n; i++) s1[i-1]=a[i]-a[i-1];
        for(int i=2; i<=n; i++) s2[i-1]=b[i]-b[i-1];
        s1[n]=a[n]-a[1];
        int f=0;
        if(n==1)
        {
            if(a[1]==b[1]||(a[1]==l-b[1])||(l-a[1]==b[1])) puts("YES");
            else puts("NO");
            continue;
        }
        for(int i=1; i<=n; i++)
            for(int j=1; j<n; j++)
                if(s1[i]==s2[j])
                {
                    int x=0;
                    int k1=i,k2=j;
                    while(s1[k1]==s2[k2]&&(x+1)!=n)
                    {
                        k1++,k2++;
                        if(k1>n) k1=1;
                        if(k2>=n) k2=1;
                        x++;
                    }
                    if(x+1==n) f=1;
                }
            memset(s1,0,sizeof(s1));
        memset(s2,0,sizeof(s2));
        for(int i=2; i<=n; i++) s1[i-1]=a[i]-a[i-1];
        for(int i=2; i<=n; i++) s2[i-1]=b[i]-b[i-1];
        s2[n]=b[n]-b[1];
        for(int i=1; i<n; i++)
            for(int j=1; j<=n; j++)
                if(s1[i]==s2[j])
                {
                    int x=0;
                    int k1=i,k2=j;
                    while(s1[k1]==s2[k2]&&(x+1)!=n)
                    {
                        k1++,k2++;
                        if(k1>=n) k1=1;
                        if(k2>n) k2=1;
                        x++;
                    }
                   if(x+1==n) f=1;
                }
        if(f) puts("YES");
        else puts("NO");
    }
    return 0;
}

/*****************************************
*****************   LYQ    ***************
*****************   YES    ***************
*UserID: secrecy                         *
*RunOJ:                                  *
*RunID:                                  *
*Submit time:                            *
*Language: G++                           *
*Result: Accepted                        *
*time:                                   *
*Memory:                                 *
*Length:                                 *
*School: NYIST                           *
*Blog: http://blog.csdn.net/nyist_tc_lyq *
*QQ:                                     *
*Tel:                                    *
*****************************************/

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <iterator>
#define M_PI 3.14159265358979323846
#define ll long long
#define mod 1073741824
#define pb(k) push_back(k)
#define mp(k,d) make_pair(k,d)
#define to_str(p,c) p="a"; p[0]=c;

using namespace std;

int main ()
{
    int l,n,a,f=0;
    int mr1[n], mr2[n];
    cin>>n>>l;
    for(int i=0;i<n;i++){
        cin>>a;
        mr1[i]=a-f;
        f=a;
    }
    mr1[0]+=l-a;

    f=0;
    for(int i=0;i<n;i++){
        cin>>a;
        mr2[i]=a-f;
        f=a;
    }
    cin>>a;
    mr2[0]+=l-a;
    for(int i=0;i<n;i++){
        bool h=1,g=1;
        for(int j=0;j<n;j++){
            if(mr1[(j+i)%n]!=mr2[j])h=0;
            if(mr2[(j+i)%n]!=mr1[j])h=0;
        }
        if(h||g)cout<<"YES";
        if(h||g)return 0;
    }
    cout<<"NO";
}

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#define one first
#define two second
#define pb push_back
#define mp make_pair
#define isize(A) int(A.size())
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define pii pair<int, int>
#define fi(I, S, N) for (int I = S; I < N; ++I)
#define fin(I, S, N) for (int I = S; I <= N; ++I)
#define rfi(I, S, N) for (int I = N - 1; I >= S; --I)
#define rfin(I, S, N) for (int I = N; I >= S; --I)

const int MAXN = 2e5;

vector<ll> a, b;

int main() {
    ios_base::sync_with_stdio(0);

    ll n, l;
    cin >> n >> l;

    ll last = 0;
    ll sum = 0;

    fi(i, 0, n) {
        ll aa;
        cin >> aa;

        sum += aa;
        if (i != 0) {
            a.pb(aa - last);
        }
        last = aa;
    }
    a.pb(l - sum);

    last = 0;
    sum = 0;

    fi(i, 0, n) {
        ll aa;
        cin >> aa;

        sum += aa;
        if (i != 0) {
            b.pb(aa - last);
        }
        last = aa;
    }

    b.pb(l - sum);

    fi(i, 0, n) {
        fi(j, 0, n) {
            int h = i, q = j;

            if (a[i] != b[j]) {
                continue;
            }

            bool fl = 0;

            while (h != i) {
                ++h, ++q;
                if (h > n) {
                    h -= n;
                }
                if (q > n) {
                    q -= n;
                }

                if (a[h] != b[q]) {
                    fl = 1;
                    break;
                }
            }

            if (!fl) {
                cout << "YES\n";
                return 0;
            }
        }
    }

    cout << "NO\n";

    return 0;
}

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define met(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
typedef long long ll;
const int maxn = 50+10;
int num[2][maxn];
int ans1[maxn];
int ans2[maxn];

int main()
{
    int n,l;
    while(cin>>n>>l)
    {
        for(int i=0;i<n;i++)
            cin>>num[0][i];
        for(int i=0;i<n;i++)
            cin>>num[1][i];
        for(int i=1;i<n;i++)
            ans1[i]=num[0][i]-num[0][i-1];
        ans1[0]=num[0][0]+l-num[0][n-1];
        for(int i=1;i<n;i++)
            ans2[i]=num[1][i]-num[1][i-1];
        ans2[0]=num[1][0]+l-num[1][n-1];
        int flag=0;
        int i,j;
        for(i=0;i<n;i++)
        {
            for(j=0;j<n;j++)
            {
                if(ans1[i]==ans2[(i+j)%n])
                    break;
            }
            if(j==n)
            {
                flag=1;
                break;
            }
        }
        if(flag)
            cout<<"NO"<<endl;
        else
            cout<<"YES"<<endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n,len,d1=0,d2=0;
    cin>>n>>len;
    int sas[n],kaf[n];
    for (int i=0;i<n;i++)
        cin>>kaf[i];
    for (int i=0;i<n;i++)
        cin>>sas[i];
    if(n>2)
    {
        for(int i=0;i<n-1;i++)
            d1+=kaf[i+1]-kaf[i];
        d1+=kaf[0]+abs(len-kaf[n-1]);
        for(int i=0;i<n-1;i++)
            d2+=sas[i+1]-sas[i];
        d2+=sas[0]+abs(len-sas[n-1]);
    }
    else
    {
        d1=kaf[1]-kaf[0];
        d2=sas[1]-sas[0];
    }
    if(d1==d2)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

#include <iostream>
#include <vector>
using namespace std;

int main() {

    int n,L;
    cin >> n >> L;
    int arrKefa[n],arrSasha[n];
    for (int i=0; i<n; i++){
        cin >> arrKefa[i];
    }
    for (int j=0;j<n; j++){
        cin >> arrSasha[j];
    }
    int L_K[n],L_S[n];

    int a=1,b=0,len,q;
    for (int k=0;k<n;k++){ if(n==1){break;}
        if(a<n){
            L_K[k] = arrKefa[a]-arrKefa[b];
            a++;b++;
        }
        if(a==n){
            q=0; len = L;
            while( (n-q-1)>0 ){

                len = len-L_K[q]; q++;
                L_K[n-1] = len;

            } if (a==n){break;}

        }

    }
    //begin here;
    int c=1,d=0;
        for (int w=0;w<n;w++){ if(n==1){break;}
        if(c<n){
            L_S[w] = arrSasha[c]-arrSasha[d];
            c++;d++;
        }
        if(c==n){
            q=0; len = L;
            while( (n-q-1)>0 ){

                len = len-L_S[q]; q++;
                L_S[n-1] = len;

            } if (c==n){break;}

        }

    }
    if(n==1){if(arrKefa[0]==arrSasha[0]){cout<<"YES";} else{cout<<"NO";}}
     //testing ...
   /* for (int t=0;t<n;t++){
        cout << L_K[t]<<" ";
    }

    for (int r=0;r<n;r++){
        cout << L_S[r]<<" ";
    }*/

    int num; bool nano=false;
    for(int y=0;y<n;y++){ if(nano || n==1){break;}
        for(int p=0;p<n;p++){ num=0;
            if(L_K[y]==L_S[p]){
                int f=y,g=p,flag=0; bool boo1=false,boo2=false,boo3=false;
                while(flag<n && !nano){
                    if(L_K[f]==L_S[g]){num++; } //boo3=true;
                    if(f==(n-1) &&!boo1){f=0; boo1=true;}
                    if(g==(n-1) &&!boo2){g=0; boo2=true;}
                    if(boo1){   if(L_K[f]==L_S[g]){num++; boo1=false;}    }
                    if(boo2){   if(L_K[f]==L_S[g]){num++; boo2=false;}    }
                   // if(L_K[f]==L_S[g]){num++;}
                    flag++;
                    f++;g++;
                }

            } if (num==n){cout<<"YES";nano=true;}
        }
    } if(!nano && n!=1){cout<<"NO";}

return 0;}

#include <bits/stdc++.h>
using namespace std;
const int MAXN=3e5+10;
typedef long long ll;
int a[MAXN];
int b[MAXN];
int c[MAXN];
int main(){
    int n,l;
    cin>>n>>l;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int tot=0;
    for(int i=1;i<n;i++){
        c[tot++]=a[i]-a[i-1];
    }
    c[tot++]=l-a[n-1]+a[0];
    for(int i=1;i<n;i++){
        c[tot++]=a[i]-a[i-1];
    }
    for(int i=0;i<tot;i++){
        cout<<c[i]<<' ';
    }cout<<endl;
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    int flag=0;
    int x=b[1]-b[0];
    for(int i=0;i<tot;i++){
        if(c[i]!=x)continue;
        else{
            int cnt=i;
            for(int j=1;j<n;j++){
                if(c[i]==b[j]-b[j-1]){
                    i++;
                    continue;
                }
                else {
                    i=-1;break;
                }
            }
            if(i==-1)i=cnt;
            else {
                flag=1;break;
            }
        }
    }
    if(flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,l;
	cin>>n>>l;
	int i,k;
	int A[n],B[n];
	int C[l];
	memset(C,0,sizeof(C));
	for(i=0;i<n;i++)
	{
		cin>>A[i];
		if(i>0)
		C[A[i]-A[i-1]]++;
	}
	for(i=0;i<n;i++)
		cin>>B[i];
	k=B[n-1]-B[0];
	if(C[l-k]!=0)
	cout<<"YES";
	else
	cout<<"NO";
	// your code goes here
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;
int n,l;
int a[100], b[100], c[100], d[100];

int main() {
    cin >> n >> l;
    for (int i=0; i<n; i++) cin >> a[i];
    for (int i=0; i<n; i++) cin >> b[i];
    for (int i=0; i<n-1; i++) {
        c[i] = a[i+1]-a[i];
        d[i] = b[i+1]-b[i];
    }
    c[n-1] = l-a[n-1]+a[0];
    d[n-1] = l-b[n-1]+b[0];
    sort(c,c+n);
    sort(d,d+n);
    for (int i=0; i<n; i++) {
        if (c[i]!=d[i]) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <cmath>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main()
{
	int l, n;
	cin >> n >> l;
	vector <int> arr1(n);
	vector <int> arr2(n);
	multiset <int> set1;
	multiset <int> set2;
	for (int i = 0; i < n; i++)
		cin >> arr1[i];
	for (int i = 0; i < n; i++)
		cin >> arr2[i];
	if (n == 1){
		cout << "YES" << endl;
		return 0;
	}
	if (n == 2){
		set1.insert(arr1[0] + (l-arr1[1]));
		set1.insert(abs(arr1[0]-arr1[1]));
		set2.insert(arr2[0] + (l - arr2[1]));
		set2.insert(abs(arr2[0] - arr2[1]));
		if (set1 == set2)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
		return 0;
	}
	set1.insert(arr1[0] + (l - arr1[n-1]));
	for (int i = 1; i < n; i++)
		set1.insert(abs(arr1[i] - arr1[i-1]));
	set2.insert(arr2[0] + (l - arr2[n-1]));
	for (int i = 1; i < n; i++)
		set2.insert(abs(arr2[i] - arr2[i - 1]));
	if (set1 == set2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

// B.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n, l;
	cin >> n >> l;
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	int add = abs(a[0] - b[0]);

	if (a[n - 1] + add == b[n - 1] || a[n - 1] == b[n - 1] + add) cout << "YES";
	else cout << "NO";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
int n,l,i,flag=1,index=0;
scanf("%d %d",&n,&l);

int kefa[n],sasha[n];
int kefasum=0,sasum=0;

for(i=0;i<n;i++)
        scanf("%d",&kefa[i]);

for(i=0;i<n;i++)
    scanf("%d",&sasha[i]);

if(n==1)
    {
    printf("YES\n");
    return 0 ;
    }

int kbar[n],sbar[n];

for(i=0;i<n-1;i++)
    {
        kbar[i]=kefa[i+1]-kefa[i];
        sbar[i]=sasha[i+1]-sasha[i];
        kefasum=kefasum+kbar[i];
        sasum=sasum+sbar[i];
    }
kbar[n-1]=l-kefasum;
sbar[n-1]=l-sasum;

for(i=0;i<n;i++)
    {
    if(sbar[i]==kbar[0])
        {
        index=i;
        break;
        }
    }

int a=0;
while(a!=n)
{
 if(index>=n)
        index=0;
 if(sbar[index]==kbar[a])
        {
         index++;
         a++;
        }
 else if(sbar[index]!=kbar[a])
    {
    flag=0;
    break;
    }
}

if(flag)
    printf("YES\n");
else
    printf("NO\n");

}

#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,l,i,x;
	cin>>n>>l;
	vector <int> v1;
	vector <int> v2;
	int a,b;
	cin>>a;
	int y=a;
	for(i=1;i<n;i++){
		cin>>x;
		v1.push_back(x-y);
		y=x;
	}
	v1.push_back(l-y+a);
	cin>>a;
	y=a;
	for(i=1;i<n;i++){
		cin>>x;
		v2.push_back(x-y);
		y=x;
	}
	v2.push_back(l-y+a);
	int f,j;
	for(i=0;i<n;i++){
		f=0;
		for(j=0;j<n;j++){
			if(v1[(i+j)%n]!=v2[(i+j)%n]){
				f=1;
				break;
			}
		}
		if(f==0){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;
	return 0;
}

#include<iostream>
using namespace std;
int zxc(int a[],int b[],int n,int len)
{
    int c[50],i,j,k,p;
    for(i=0;i<n;i++)
    {
    	c[i]=a[i]-b[0];
    	if(c[i]<0)
    	c[i]+=len;
	}
	for(i=0;i<n;i++)
	{
		j=i;
		p=0;
		for(k=0;k<n;k++)
		{
			if((a[j+k]-b[k]==c[i])||(a[j+k])-b[k]+len==c[i])
			p++;
			else
			break;
			if(j+k==n-1)
			j=j+k-n;
		}
		if(p==n)
		return 1;
	}
	return 0;
}
int main()
{
	int n,l,i,k;
	cin>>n>>l;
	int a[50],b[50];
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<n;i++)
	cin>>b[i];
	k=zxc(a,b,n,l);
	if(k==1)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}

#include <iostream>
#include <algorithm>

using namespace std;

int main()
	{
	int n, l, a[51], b[51], dif, i,ok, s;
	cin>>n>>l;
	for( i=1; i<=n; i++ )
		cin>>a[i];
	for( i=1; i<=n; i++ )
		cin>>b[i];
	dif=abs( a[1]-b[1] );
	ok=1;
	for( i=1; i<=n && ok==1; i++ )
		if( abs( a[i]-b[i] )!=dif )
			ok=0;
	if( ok==0 )
			{
			s=0;
			for( i=1; i<n; i++ )
				s+=a[i+1]-a[i];
			if( l-s==abs(b[2]-b[1]) )
				ok=1;
			}
	if( ok==1 )
		cout<<"YES";
	else
		cout<<"NO";
	return 0;
	}

#include<bits/stdc++.h>
using namespace std;

main()
{
    int n,L;
    cin>>n>>L;
    int K[n],S[n],k[n],s[n];

    for(int i=0 ; i<n ; i++)
        cin>>K[i];
    for(int i=0 ; i<n ; i++)
        cin>>S[i];

    for(int i=0 ; i<n ; i++)
    {
        if(i == n-1)
        {
            k[i] = K[0]+L - K[i];
            s[i] = S[0]+L - S[i];
            break;
        }
        k[i] = K[i+1] - K[i];
        s[i] = S[i+1] - S[i];
    }
    /*for(int i=0 ; i<n ; i++)
        cout<<k[i]<<" ";
    cout<<endl;
    for(int i=0 ; i<n ; i++)
        cout<<s[i]<<" ";
    cout<<endl;*/

    sort(k,k+n);
    sort(s,s+n);
    /*for(int i=0 ; i<n ; i++)
        cout<<k[i]<<" ";
    cout<<endl;
    for(int i=0 ; i<n ; i++)
        cout<<s[i]<<" ";
    cout<<endl;*/

    for(int i=0 ; i<n ; i++)
    {
        if(s[i] != k[i])
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }

    cout<<"YES"<<endl;
}

// https://vk.cc/avzJO3
//#define _GLIBCXX_DEBUG
//#define _GLIBCXX_PARALLEL
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
using namespace std;

const int maxn = 1e5 * 4;

inline int g() {
    int x;
    cin >> x;
    return x;
}

inline long long gl() {
    long long x;
    cin >> x;
    return x;
}

inline char gc() {
    char x;
    cin >> x;
    return x;
}

inline string gs() {
    string s;
    cin >> s;
    return s;
}

template<typename T>
inline vector<T> gv(int len) {
    vector<T> a(len);
    for (auto &it : a)
        cin >> it;
    return a;
}

inline vector<int> gv(int len) {
    vector<int> a(len);
    for (auto &it : a)
        cin >> it;
    return a;
}

inline vector<pair<int, int>> gv_andPairCnt(int len) {
    vector<pair<int, int>> a(len);
    int i = 1;
    for (auto &it : a) {
        it.second = i;
        i++;
        cin >> it.first;
    }
    return a;
}

double power_log(double power, double val) {
    return log(val) / log(power);
}

template <typename T>
T sqr(T x) { return x * x; }

#define rep(I, N) for (int I = 0; I < (N); ++I)
#define rep_range(VALUE, LEFT, RIGHT) for (int VALUE = (LEFT); VALUE < (RIGHT); ++VALUE)

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (auto it : v)
        os << it << " ";
    os << "\n";
    return os;
}

template<typename T, typename H>
inline vector<pair<T, H>> gv_andBiPair(int len) {
    vector<pair<T, H>> a(len);
    for (auto &it : a) {
        cin >> it.first >> it.second;
    }
    return a;
}

template<typename T>
inline set<T> vector_to_set(const vector<T> &vec) {
    set<T> s;
    for (auto &it : vec)
        s.insert(it);
    return s;
}

const long long md = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n = g (), l = g();

    auto ok = [l](deque<int> a, deque<int> b){
        set<int> st;
        rep(i, a.size()) {
            int x = (a[i] - b[i]) + l;
            st.insert(x % l);
        }
        cout << st.size() << "\n";
        return st.size() == 1;
    };
    deque<int> a, b;
    rep(i, n) {
        a.push_back(g());
    }
    rep(i, n) {
        b.push_back(g());
    }
    rep(t, n + 1) {
        if(ok(a, b)) {
            return cout << "YES", 0;
        }
        a.push_back(a.front());
        a.pop_front();
    }
    cout << "NO";
}

#include<bits/stdc++.h>
#include<map>
#include<unordered_map>
#define pb push_back
#define mp make_pair
const int s = 10 + 1e5;
typedef long long ll;
typedef unsigned long long ull;
#define all(a) a.begin(),a.end()
#define endl '\n'

/*

███╗   ███╗███████╗███╗   ███╗███████╗    ██╗      ██████╗ ██████╗ ██████╗
████╗ ████║██╔════╝████╗ ████║██╔════╝    ██║     ██╔═══██╗██╔══██╗██╔══██╗
██╔████╔██║█████╗  ██╔████╔██║█████╗      ██║     ██║   ██║██████╔╝██║  ██║
██║╚██╔╝██║██╔══╝  ██║╚██╔╝██║██╔══╝      ██║     ██║   ██║██╔══██╗██║  ██║
██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║███████╗    ███████╗╚██████╔╝██║  ██║██████╔╝
╚═╝     ╚═╝╚══════╝╚═╝     ╚═╝╚══════╝    ╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚═════╝

*/

using namespace std;
void Khoukha() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
map<int, int>Mp;
int f[101];
int f2[101];
int main() {
	Khoukha();
	int l, n; cin >> n >> l;
	vector<int>n1(n);
	vector<int>n2(n);
	for (int i = 0; i < n; ++i) {
		cin >> n1[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> n2[i];
	}
	for (int i = 0; i < n-1; ++i) {
		f[abs(n1[i] - n1[i + 1])]++;
	}
	for (int i = 0; i < n-1; ++i) {
		f2[abs(n2[i] - n2[i + 1])]++;
	}
	int t1 = l - n1[n - 1] + n1[0];
	int t2 = l - n2[n - 1] + n2[0];
	f[t1]++;
	f2[t2]++;
	for (int i = 0; i < 101; ++i) {
		if (f[i] != f2[i])
			return cout << "NO", 0;
	}
	cout << "YES";
	return 0;

}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?), set tle
	* do smth instead of nothing and stay organized
*/

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	ll n, m, a[51], b[51], x;
	set<int> s;
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < 0; i++) s.insert(a[i] - b[i]);
	cout << (s.size() > 1) ? "NO\n" : "YES\n";
}

#include <iostream>

using std::cout;
using std::cin;

bool a1[200], a2[100];

int main() {
    int i, j, t, tMax, n, l, first = -1;
    cin >> n >> l;
    for (i = 0; i < n; ++i) {
		cin >> t;
		a1[t] = true;
		a1[t + l] = true;
	}
    for (i = 0; i < n; ++i) {
		cin >> t;
		a2[t] = true;
	}
	bool found;
	for (i = 0; i < l; ++i) {
		found = true;
		for (j = 0; j < l; ++j) {
			if (a1[j + t] != a2[j]) {
				found = false;
				break;
			}
		}
		if (found) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}

//
//  main.cpp
//  Codeforces Round #394 (Div. 2) - B. Dasha and friends
//
//  Created by S M HEMEL on 5/10/17.
//  Copyright © 2017 Eastern University. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int a[100],b[100];
int main()
{
    int n,m;
    cin >> n >> m;
    for(int i=0; i<n; cin >> a[i],i++);
    for(int i=0; i<n; cin >> b[i],i++);
    int x[100],x1[100];
    int l=0;
    for(int i=1; i<n; i++){
        x[l] = abs(a[i-1]-a[i]);
        x1[l++] = abs(b[i-1]-b[i]);
    }
    x[l] = abs(a[n-1]-m)+abs(0-a[0]);
    x1[l++] = abs(b[n-1]-m)+ abs(0-b[0]);
    sort(x,x+l);
    sort(x1,x1+l);
    for(int i=0; i<n; i++){
        if(x[i]!=x1[i])
            return 0 * puts("NO");
    }
    puts("YES");
    return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define M 1000000007
#define INF 9223372036854775807
#define pmp(x,y) push_back(make_pair(x,y))
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define ld double
#define PI 3.14159265
#define len(a) (ll)a.size()
#define F first
#define S second
#define ch cout<<"debug\n"
#define cin(x) scanf("%lld",&x);
using namespace std;
ll a[200],b[200],c[200],d[200],e[201];
int main()
{
	ll n,l;
	cin>>n>>l;

	//n>2
	for(ll i=0;i<n;i++)
		cin>>a[i];

	for(ll i=0;i<n;i++)
		cin>>b[i];

	if(n==1)
	{
		cout<<"YES";
		return 0;

	}

	for(ll i=0;i<n-1;i++)
		c[i]=a[i+1]-a[i];

	c[n-1]=l-a[n-1]+a[0];

	for(ll i=0;i<n-1;i++)
		d[i]=b[i+1]-b[i];

	d[n-1]=l-b[n-1]+b[0];

	ll flag=0;

		for(ll j=0;j<n;j++)
		{

			if(c[0]==d[j])
			{
				ll k=0;
				for(k=0;k<n;k++)
				{
					if(c[k]!=d[(j+k)%n])
						continue;
				}

				if(k==n)
				{
					flag=1;
					break;
				}

			}
		}

	for(ll i=0;i<n;i++)
		e[i]=c[i];

	for(ll i=0;i<n;i++)
		c[i]=e[n-i-1];

	for(ll j=0;j<n;j++)
		{

			if(c[0]==d[j])
			{
				ll k=0;
				for(k=0;k<n;k++)
				{
					if(c[k]!=d[(j+k)%n])
						continue;
				}

				if(k==n)
				{
					flag=1;
					break;
				}

			}
		}

	if(flag==1)
	cout<<"YES";
	else
	cout<<"NO";

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define rsrt(s) sort(s.rbegin(),s.rend())
#define all(x) x.begin(),x.end()
#define mem(a, b) memset(a, b, sizeof(a))

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    ll n,l;

    cin >>  n >> l;
    vector <ll> a(n),a1(n),b(n),b1(n);

    for(auto &i : a) cin >> i;
    for(auto &i : b) cin >> i;
    a1=a;
    b1=b;

    for(ll i=1;i<n;i++)
    {
        a1[i]=a[i]-a[i-1];
        b1[i]=b[i]-b[i-1];
    }

    ll ans=0;
    for(ll i=1;i<n;i++) ans+=a1[i];

    for(ll i=1;i<n-1;i++) ans+=b1[i];

    //for(auto i : a) cout <<  i << ' ';

    //cout << ans;
    if(ans==l) cout << "YES\n";
    else cout  << "NO\n";

    //---------------------------------

    return 0;
}

//
//  main.cpp
//  CF #394 B
//
//  Created by 赵奕 on 17/1/21.
//  Copyright © 2017年 赵奕. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define N 1010
#define rep(i,a,b) for (int i=(a);i<=(b);++i)
#define rep2(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
int tot,n,m,ans,p[N],a[N],b[N],x[N],y[N];
string s;
bool find(int a[],int b[])
{
    int i,j,k;
    rep (i,1,n-1)
    if (b[i]==a[1])
    {
        j = 1;
        while (i+j-1<n-1&&b[i+j-1]==a[j])
            j++;
        if (i+j-1==n-1)
        {
            //k = 1;
            //while (j+k+1<n-1&&a[j+k+1]==b[k])
            //    k++;
            //if (j+k+1==n-1)
            //    return true;
            bool t = true;
            for (k = 1,j = j+2; j <= n-1; ++k,++j)
            if (a[j]!=b[k])
            {
                t = false;
                break;
            }
            if (t)
                return true;
        }
    }
    return false;
}
int main(int argc, const char * argv[])
{
    int i,j,k,ans;
    cin >> n >> m;
    rep (i,1,n){
        scanf("%d",&a[i]);
        if (i > 1)
        {
            x[i-1] = a[i]-a[i-1];
        }
    }
    rep (i,1,n){
        scanf("%d",&b[i]);
        if (i > 1)
        {
            y[i-1] = b[i]-b[i-1];
        }
    }

    if (!find(x,y)&&!find(y,x))
    {
        puts("NO");
        return 0;
    }
    puts("YES");
    return 0;
}

#include <iostream>
#include <vector>
using namespace std;
int main(){
	short n,l,i,x,y,z;
		cin>>n>>l;
		vector<short>v(n);
		for(i=0;i<n;i++)cin>>v[i];
		cin>>i;
		x=abs(v[0]-i);y=l-x;
		for(i=1;i<n;i++){
			cin>>z;
			if(!(abs(v[i]-z)==x||l-abs(v[i]-z)==y)){cout<<"NO"<<endl;return 0;}
		}
		cout<<"YES"<<endl;
	return 0;
}

#include <bits/stdc++.h>
#define endl '\n'
#define modulo 1000000007
#define PI acos(-1)
#pragma GCC target ("avx2")
//#pragma GCC optimize("trapv")
#define int long long
#define sinDegrees(x) sin((x) * PI / 180.0)
#define cosDegrees(x) cos((x) * PI / 180.0)
#define tanDegrees(x) tan((x) * PI / 180.0)
#define atanDegrees(x) atan(x)* 180.0 / PI
using namespace std;
int power(int x,int y,int m)
{
int temp;
if(y == 0)
return 1;
temp = (power(x, y/2,m))%m;
if (y%2 == 0)
return ((temp%m)*temp);
else
return ((x*temp%m)*temp%m)%m;
}
int inv(int x)
{
return (power(x,modulo-2,modulo))%modulo;
}
bool comp(int a,int b)
{
return a>b;
}
int32_t main()
{
//freopen("output.txt","w", stdout);
//freopen("rect.in","r", stdin);
iostream::sync_with_stdio(0);
cin.tie(0);
int n,m;
cin>>n>>m;
int arr[n],arr2[n];
for(int i=0;i<n;i++)
cin>>arr[i];
for(int i=0;i<n;i++)
cin>>arr2[i];
for(int l=0;l<5000;l++){
bool flag=0;
for(int i=0;i<n;i++){
if((arr[i]+l)%m!=arr2[i]&&(((arr[i]-l)%m)+m)%m!=arr2[i]){
flag=1;
break;
}
}
if(!flag){
cout<<"YES";
exit(0);
}
}
cout<<"NO";
return 0;
}

#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main() {
    int n,l;
    int eq=1;
    cin>>n>>l;
    int a[n],b[n],c[n],d[n];
    cin>>a[0];
    for(int i=1;i<n;i++)
    {
    	cin>>a[i];
    	c[i-1]=a[i]-a[i-1];
    }
    cin>>b[0];
    for(int i=1;i<n;i++)
    {
    	cin>>b[i];
    	d[i-1]=b[i]-b[i-1];
    }
    c[n-1]=l-a[n-1]+a[0];
    d[n-1]=l-b[n-1]+b[0];
    sort(c,c+n);
    sort(d,d+n);
    for(int i=0;i<n;i++)
    {
    	if(c[i]!=d[i])
    	{
    	//	cout<<c[i]<<" "<<d[i];
    		eq=0;
    		break;
    	}
    }
    if(eq==1)
    {
    	cout<<"YES";
    }
    else
    {
    	cout<<"NO";
    }
	return 0;
}

                                      ///  ***  In The Name of God ... ***  ///
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !
/// Lanat be Stress ... ! Khodaya khodet komak kon :D !

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define bug() cout << "BUG" << endl ;
#define X first
#define Y second
#define Size(x) (int)x.size()
typedef long long ll;
const ll INF = 1e18 ;

const ll MAXN = 50 + 20 ;
ll n , l , a[MAXN] , b[MAXN] , A[MAXN] , B[MAXN] ;

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> l ;
	for(ll i = 0 ; i < n ; i++)
		cin >> a[i] ;
	for(ll j = 0 ; j < n ; j++)
		cin >> b[j] ;
	for(ll i = 1 ; i < n ; i++)
		A[i - 1] = a[i] - a[i - 1] ;
	for(ll i = 1 ; i < n ; i++)
		B[i - 1] = b[i] - b[i - 1] ;
	A[n - 1] = l - a[n - 1] + a[0] ;
	B[n - 1] = l - b[n - 1] + a[0] ;
	for(ll i = 0 ; i < n ; i++)
		if(A[i] == B[i])
			return cout << "YES" , 0 ;
	cout << "NO" ;
}

#include<bits/stdc++.h>
using namespace std;
int main()
  {
      int a,l,flag=0;
      cin>>a>>l;
 int arr1[a],arr2[a];
 for(int i=0;i<a;i++)
      cin>>arr1[i];
 for(int i=0;i<a;i++)
      cin>>arr2[i];
int cou=0,cou1=0;

int tmp1[a],tmp2[a],val;
           for(int i=1;i<a;i++)

               tmp1[i-1]=arr1[i]-arr1[i-1];
               tmp1[a-1]=(l-arr1[a-1]+arr1[0]);

              for(int i=1;i<a;i++)

               tmp2[i-1]=arr2[i]-arr2[i-1];
            tmp2[a-1]=(l-arr2[a-1]+arr2[0]);

           for(int i=0;i<a;i++)
               if(tmp1[i]==tmp2[0])
           {
              // cout<<i;
               val=i;break;
           }val++;
          for(int i=1;i<a;i++)
           {
               if(tmp1[val%a]!=tmp2[i])
               {//cout<<"   "<<tmp1[val%(a-1)]<<" "<<tmp2[i];
                   flag=1;
                   break;
               }
               val++;
           }

           if(flag)
            cout<<"NO";
           else
            cout<<"YES";

  }

#include<bits/stdc++.h>
using namespace std;
int a[200],b[200];
int main()
{
    int n,j,i,L,k,c=0;
    cin>>n>>L;k=L;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<n;i++) cin>>b[i];
    for(i=0;i<(n-1);i++){
        a[i]=a[i+1]-a[i];
        L=L-a[i];
        b[i]=b[i+1]-b[i];
        k=k-b[i];
    }
    a[n-1]=L; b[n-1]=k;
    sort(a,a+n); sort(b,b+n);
    for(i=0;i<n;i++){
        if(a[i]!=b[i]) c++;
    }
    if(c==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

#include <iostream>
#include <algorithm>
using namespace std;

int n, l;
int a[51], b[51];

int main() {
	cin >> n >> l;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool fl = false;
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		if (a[i] != b[i]) fl = true;
	}
	if (!fl) {
		cout << "YES";
		return 0;
	}
	int i = 0;
	while (i != l) {
		for (int j = 1; j < n; j++) {
			a[j]--;
		}
		if (a[0]) a[0]--;
		bool f = false;
		for (int j = 0; j < n; j++) {
			if (a[j] != b[j]) f = true;
		}
		if (!f) {
			cout << "YES";
			return 0;
		}
		if (!a[0]) {
			a[n] = l;
			int j = 0;
			while (j != n) { a[j] = a[j + 1], j++; }
		}
		f = false;
		for (int j = 0; j < n; j++) {
			if (a[j] != b[j]) f = true;
		}
		if (!f) {
			cout << "YES";
			return 0;
		}
		i++;
	}
	cout << "NO";
	return 0;
}

//"How You Look at it is Petty Much How You'll See it."
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<long long int> vll;
typedef vector<pii> vpi;
const ll Mod = 998244353;
const ll mod = 1e9+7;

#define PI 3.1415926535897932384626
#define f(i, a, b) for(int i=a; i<=b; i++)
#define F(i, n) for(int i=0; i<n; i++)
#define rf(i, a, b) for(int i=a; i>=b; i--)
#define ps(x) fixed<<setprecision(x)
#define all(x) (x).begin(), (x).end()
#define test(t) int t; cin>>t; while(t--){solve();}
#define vvp vector<vector<pair<int, int>>>
#define prq priority_queue<pii, vector<pii>, greater<pii>>

#define pb push_back
#define pf push_front
#define mp make_pair
#define si set <int>
#define db double
#define bg begin
#define sz size
#define fi first
#define se second
#define nl "\n"

ll Pow(ll a,ll b){ a=a%mod; ll res=1;
	while(b){ if(b&1)  res=(res*a)%mod;  a=(a*a)%mod; b>>=1; }
	return (res%mod); }
ll modInverse(ll a, ll m) { return Pow(a, m-2); }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
ll lcm(ll a, ll b) { return (a*b)/gcd(a,b); }
//-------------------------------------------------------------------------------------//

void solve()
{
	int n, l;
	cin>>n>>l;
	int a[n], b[n];
	F(i, n) cin>>a[i];
	F(i, n) cin>>b[i];
	bool bo =true;
	int k=abs(a[0]-b[0]);
	F(i, n){
		if(abs(a[i]-b[i])!=k){
			bo=false;
			break;
		}
	}
	if(bo)
		cout<<"YES"<<nl;
	else
		cout<<"NO"<<nl;
}
//-------------------------------------------------------------------------------------//

/*The Best Thing About a Boolean is Even if you are Wrong,You are Only off by a Bit.*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	#ifndef ONLINE_JUDGE
	  freopen ("input.txt" , "r" , stdin);
	  	freopen ("output.txt", "w" , stdout);
	#endif

	solve();
	//test(t);

	#ifndef ONLINE_JUDGE
    	cerr<<"\nTime Taken : "<<1.0*clock()/CLOCKS_PER_SEC<<" sec\n";
	#endif
	return 0;
}

#include<iostream>
#include<stdio.h>
#include<algorithm>

using namespace std;

int main()
{
int n,l,i,j,k;
scanf("%d%d",&n,&l);
int a[n],b[n];

	scanf("%d",&j);
	int m=j;
	for(i=0;i<n-1;i++)
	{
	scanf("%d",&k);
	a[i]=k-j;
	j=k;
	}
	a[n-1]=(m+l-j);

sort(a,a+n);

	scanf("%d",&j);
	m=j;
	for(i=0;i<n-1;i++)
	{
	scanf("%d",&k);
	b[i]=k-j;
	j=k;
	}
	b[n-1]=(m+l-j);
sort(b,b+n);
	i=0;
	while(i<n)
	{
	if(a[i]==b[i])
	i++;
	else
	break;
	}

if(i==n)
	printf("YES");
else
	printf("NO");

return 0;
}

#include <iostream>

using namespace std;

int main(){
	int n, L, i, j;
	int dK[50], dS[50];
	int obs[100]={0};

	cin>>n>>L;

	for(i=0;i<n;i++){
		cin>>dK[i];
		obs[dK[i]-1]=1;
	}

	for(i=0;i<n;i++)
		cin>>dS[i];

	int dist;
	int is=0;

	for(i=0;i<L;i++){
		for(j=0;j<n;j++){
			dist=i+dS[j];
			if(dist > L-1) dist -= L;
			//cout<<"dist= "<<dist<<" obs[dist]= "<<obs[dist]<<endl;
			if(obs[dist]!=1) break;
		}

		if(j==n){
			is=1;
			break;
		}
	}

	if(is)
		cout<<"YES";
	else
		cout<<"NO";
}

#include<bits/stdc++.h>
using namespace std;
int main()
  {
      int a,l,flag=0;
      cin>>a>>l;
 int arr1[a],arr2[a];
 for(int i=0;i<a;i++)
      cin>>arr1[i];
 for(int i=0;i<a;i++)
      cin>>arr2[i];
int cou=0,cou1=0;

           for(int i=0;i<a;i++)
           {
               if(arr1[i]==arr2[i])
               {
                   flag=1;
                   break;
               }
           }
           if(flag)
            cout<<"NO";
           else
            cout<<"YES";

  }

#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lld long long int
#define ll long double
#define p(x) cout<<x<<endl
#define vect(x,n) vector<lld>x(n,0)
#define sorta(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.begin(),v.end(),greater<lld>())
#define all(v) v.begin(),v.end()
#define matrix(x,n,m) vector<vector<lld>>x(n,vector<lld>(m,0))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define lb lower_bound
#define F first
#define S second
#define pb push_back
#define mkp make_pair
const lld mod=1e9+7;
lld pow(lld x, lld y) { lld res = 1; while (y >(lld)0) { if (y &(lld)1) res = ((res) * (x)); y = y >>(lld)1; x = ((x) * (x)); } return res; }

void solve()
{
    lld i,j,k,ans,a,b,c,mx,mn,t,n,m,x,temp,p,q,y,z,l,r,g,flg,sum,d,cnt,sumf,diff,odd,even;
    cin>>n>>a;
    vector<lld>arr1(n),arr2(n),sasha,kefa;
    for(i=0;i<n;i++)
        cin>>arr1[i];
    for(i=0;i<n;i++)
        cin>>arr2[i];
    if(n==1)
    {
        p("YES");
        return;
    }
    sorta(arr1);
    sorta(arr2);
    for(i=1;i<n;i++)
        sasha.pb(arr1[i]-arr1[i-1]);
    sasha.pb(arr1[0]+a-arr1[n-1]);
    for(i=1;i<n;i++)
        kefa.pb(arr2[i]-arr2[i-1]);
    kefa.pb(arr2[0]+a-arr2[n-1]);
    sorta(sasha);
    sorta(kefa);
    if(sasha==kefa)
        p("YES");
    else
        p("NO");
    return;
}

int main()
{
    fast;
    lld t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

#include <bits/stdc++.h>
using namespace std;

long long n,l,a[100],b[100];

int main() {
  //  freopen("test.txt","r",stdin);
    cin >> n >> l;
    for (int i=1 ; i<= n ; i++) {
        cin >> a[i];
    }
    for (int i=1; i<=n; i++) {
        cin >> b[i];
    }
    int tmp = abs(a[1] - b[1]) ;
    for (int i=2 ; i<=n ;i++) {
        if (abs(a[i] - b[i]) != tmp) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}

#include<bits/stdc++.h>
using namespace std;
int main()
{
       long long n,m,a,b;
       cin>>n>>m;
       set<int>s;
       vector<int>v1;
       for(int i=0;i<n;i++)
       {
              cin>>a;
              v1.push_back(a);
       }
       vector<int>v2;
       for(int i=0;i<n;i++)
       {
              cin>>a;
              v2.push_back(a);
       }
       for(int i=0;i<n;i++)
       {
              s.insert(abs(v1[i]-v2[i]));
       }
       if(s.size()==1)
       cout<<"YES";
       else
       cout<<"NO";
       return 0;
}

# include <bits/stdc++.h>

using namespace std;

#define pii pair <int, int>
#define pll pair <ll, ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define maxe *max_element
#define fi first
#define se second
#define y0 Zhasulan
#define y1 Nurlynek

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (ll)4e5 + 7;
const int lmaxn = (int)1e6 + 7;
const ll linf = (ll)1e18 + 7;

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
bool isprime(ll x){
    ll q = 0;
    if(x == 1)
        return false;
    for(ll i = 2; i * i <= x; i++){
        if(x % i == 0){
            return false;
        }
    }
    return true;
}
ll n, m, k, t, a[maxn], b[maxn], c[maxn];
bool w;
//char c[maxn];
int main(){
    cin >> n >> m;
    if(n == 1){
        cout << "YES";
        return 0;
    }
    for(ll i = 1; i <= n; i++)
        cin >> a[i];
    for(ll i = 1; i <= n; i++)
        cin >> b[i];
    for(ll i = 1; i <= n; i++)
        c[i] = b[i] - a[1];
    ll k = 1;
    for(ll o = -100; o <= 100; o++){
    for(ll i = 1; i <= n; i++){
        w = false, k = i;
        for(ll j = 1; j <= n; j++){
            ll pos = a[j] + o;
            if(a[j] + o < 0)
                m = -m;
            if(a[j] + o > m)
                pos %= m;
            if(b[k] != pos)
            {
                w = true;
            }
            k++;
            if(k > n)
                k %= n;
        }
        if(!w){
            cout << "YES";
            return 0;
        }
    }
    }
    cout << "NO";
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long LL;

const int MX = 50 + 10;

int n,L;
int a[MX],b[MX];

int main(){
    cin >> n >> L;
    for(int i = 0;i < n;i++)
        cin >> a[i];
    for(int i = 0;i < n;i++)
        cin >> b[i];
    int check = a[0]-b[0];
    int flag = 1;
    for(int i = 1;i < n;i++){
        if(a[i] - b[i] != check){
            flag = 1;
            break;
        }
    }
    if(flag)
        puts("YES");
    else
        puts("NO");
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define fi first
//#define se second
#define descen greater<ll>()
#define start int t;cin>>t;while(t--)
#define f(n) for(ll i=0;i<n;i++)
#define fk(i,k,n) for(ll i=k;i<=n;i++)
#define fr(n) for(ll i=n-1;i>=0;i--)
#define al(s) s.begin(),s.end()
#define vl vector<ll>
#define vi vector<int>
#define vll vector<pair<ll,ll>>;
#define str string
#define pb push_back
#define pll pair<ll,ll>
#define ln  cout<<endl
#define mp  make_pair
#define mll map<ll,ll>
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define watch(x) cout<<(#x)<<" is "<<x<<endl
#define MOD 1000000007
bool isEven(ll n){return (!(n&1));}
bool isPowerOfTwo (ll x){return x && (!(x&(x-1)));}
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll isPrime(ll n){ll p=(ll)sqrt(n);fk(i,2,p) if(n%i==0) return 0;return 1;}
ll powmod(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
const int N=2e5+20;
void rotate(int arr[], int n)
{
    int temp = arr[0], i;
    for (i = 0; i < n - 1; i++)
        arr[i] = arr[i + 1];

    arr[i] = temp;
}
bool areEqual(int arr1[], int arr2[], int n, int m)
{
    // If lengths of array are not equal means
    // array are not equal
    if (n != m)
        return false;

    // Sort both arrays
    sort(arr1, arr1 + n);
    sort(arr2, arr2 + m);

    // Linearly compare elements
    for (int i = 0; i < n; i++)
        if (arr1[i] != arr2[i])
            return false;

    // If all elements were same.
    return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

  int n,l;
  cin>>n>>l;
  int v1[n],v2[n],ans1[n],ans2[n];
  f(n)
  {
    int k;
    cin>>k;
    v1[i]=k;
  }
  f(n)
  {
    int k;
    cin>>k;
    v2[i]=k;
  }
  adjacent_difference(v1,v1+n,ans1);
  adjacent_difference(v2,v2+n,ans2);
  ans1[0]+=(l-v1[n-1]);
  ans2[0]+=(l-v2[n-1]);
  /*f(n)
  cout<<ans1[i]<<" ";
  ln;
  f(n)
  cout<<ans2[i]<<" ";
  ln;*/

    f(n+1)
    {

    /*  f(n)
      cout<<ans1[i]<<" ";
      ln;*/
      if(areEqual(ans1,ans2,n,n))
      {
        cout<<"YES";
        return 0;
      }
      rotate(ans1,n);
    }

  cout<<"NO";

}

#include <bits/stdc++.h>

#define pfor(i, n) for (int i = 0; i < (n); i++)
#define rfor(i, n) for (int i = (n) - 1; i >= 0; i--)
#define re return

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef string str;

int a[100], b[100];

vector <int> v;

int main()
{
	int n, l;
	cin >> n >> l;
	pfor(i, n)
		cin >> a[i];
	pfor(i, n)
		cin >> b[i];
	int s = 0;
	for(int i = n - 1; i >= 1; i--)
	{
		a[i] = a[i] - a[i - 1];
		s += a[i];
	}
	a[0] = l - s;
	int y = 0;
	for(int i = n - 1; i >= 1; i--)
	{
		b[i] = b[i] - b[i - 1];
		y += b[i];
	}
	b[0] = l - y;
	for(int i = 0; i < n; i++)
		v.push_back(b[i]);
	for(int i = 0; i < n; i++)
		v.push_back(b[i]);
	int u = 0;
	pfor(i, v.size())
	{
		pfor(j ,n)
		{
			if(a[j] == v[i])
				u++;
			if (a[j] != v[i] || j == n - 1)
			{
				if (u == n)
				{
					cout << "YES";
					re 0;
				}
			}
		}
	}
	cout << "NO" << endl;
	re 0;
}

#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
#define MX 10000008
#define lp(i,n) for(ll i = 0 ; i < n ;i++)
const int N =pow(10,6), OO = 0x3f3f3f3f;

int n , l ;
int arr1[55],arr2[55],arr12[55],arr22[55];
set<int>ans;
int main () {
cin >> n >> l ;
lp(i,n)cin >>arr1[i];
lp(i,n)cin >>arr2[i];

arr12[0]=l-arr1[n-1]+arr1[0];
arr22[0]=l-arr2[n-1]+arr2[0];
ans.insert(arr12[0]);
for (int i=1;i<n;i++)
{
    arr12[i]=arr1[i]-arr1[i-1];
    ans.insert(arr12[i]);
    arr22[i]=arr2[i]-arr2[i-1];
}

    for (auto it:ans)
    {
         if(count(arr12,arr12+n,it)!=count(arr22,arr22+n,it) )
         {
             cout << "NO";
             return 0;
         }
    }
    cout <<"YES";

    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

int main()
{
    int n, l;
    scanf("%d%d", &n, &l);
    vector <int> k(n, 0);
    vector <int> s(n, 0);
    for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		k[i] = a;
    }
    for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		s[i] = a;
    }
    int dk = k[n-1];
    int ds = s[n-1];
    for (int i = n-1; i > 0; i--){
		k[i] -= k[i-1];
		s[i] -= s[i-1];
    }
    k[0] = k[0] - dk + 8;
    s[0] = s[0] - ds + 8;
    for (int d = 0; d < n; d++){
		bool b = true;
		for (int i = 0; i < n; i++){
			if (k[i] != s[(i+d) % n]){
				b = false;
				i = n;
			}
		}
		if (b){
			printf("YES");
			return 0;
		}
    }
    printf("NO");
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int N=1e5+5;
#define ll long long int
#define scl(c) scanf("%lld",&c);
#define sc(c) scanf("%d",&c);
#define pf(c) printf("%d\n",c);
#define pfl(c) printf("%lld\n",c);
#define pfs(c) printf("%d ",c);
vector< pair<ll,ll> >v;
bool cmp(pair<int,int>p1,pair<int,int>p2){
    if(p1.second != p2.second)
        return p1.second>p2.second;
    else{
        return p1.first<p2.first;
    }
}
int main()
{
    ll n,l;
    set<ll>st;
    st.clear();
    cin>>n>>l;
    if(n==1){
        cout<<"YES\n";
        return 0;
    }
    ll a[n+1],b[n+1];
    cin>>a[0];
    for(int i=1;i<n;i++){
        cin>>a[i];
        st.insert(a[i]-a[i-1]);
    }
    st.insert(l-a[n-1]+a[0]);
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    int flg=0;
    for(int i=1;i<n;i++){
        if(st.find(b[i]-b[i-1])==st.end() && !flg){
            flg=1;
            break;
        }
    }
    if(st.find(l-b[n-1]+b[0])==st.end() && !flg){
        cout<<"NO\n";
        return 0;
    }
    else{
        cout<<"YES\n";
    }

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#define one first
#define two second
#define pb push_back
#define mp make_pair
#define isize(A) int(A.size())
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define pii pair<int, int>
#define fi(I, S, N) for (int I = S; I < N; ++I)
#define fin(I, S, N) for (int I = S; I <= N; ++I)
#define rfi(I, S, N) for (int I = N - 1; I >= S; --I)
#define rfin(I, S, N) for (int I = N; I >= S; --I)

const int MAXN = 2e5;

vector<ll> a, b;

int main() {
    ios_base::sync_with_stdio(0);

    ll n, l;
    cin >> n >> l;

    ll last = 0;

    fi(i, 0, n) {
        ll aa;
        cin >> aa;

        if (i != 0) {
            a.pb(aa - last);
        }
        last = aa;
    }
    a.pb(l - a[isize(a) - 1]);

    last = 0;

    fi(i, 0, n) {
        ll aa;
        cin >> aa;

        if (i != 0) {
            b.pb(aa - last);
        }

        last = aa;
    }

    b.pb(l - b[isize(b) - 1]);

    if (n == 1) {
        cout << "YES\n";
        return 0;
    }

    fi(i, 0, n) {
        fi(j, 0, n) {
            int h = i, q = j;

            if (a[i] != b[j]) {
                continue;
            }

            bool fl = 0;

            while (h != i) {
                ++h, ++q;
                if (h > n) {
                    h -= n;
                }
                if (q > n) {
                    q -= n;
                }

                if (a[h] != b[q]) {
                    fl = 1;
                    break;
                }
            }

            if (!fl) {
                cout << "YES\n";
                return 0;
            }
        }
    }

    cout << "NO\n";

    return 0;
}

#include<iostream>
#include<stdio.h>
#include<cstdlib>
using namespace std;
int main()
{
  int dif,i,l,b,A[100],B[100];
  int flag = 0;
  cin>>b;
  cin>>l;
    for(i=0;i<b;i++)
    {
      cin>>A[i];
    }
    for(i=0;i<b;i++)
    {
      cin>>B[i];
    }
    if(b==1)
      cout<<"YES";
    else
    {
      dif = abs(A[0]-B[0]);
      for(i=1;i<b;i++)
      {
          if(abs(A[i]-B[i]) == dif)
            flag++;
          else
          {
            cout<<"NO";
            break;
          }
      }
    if(flag==(b-1))
      cout<<"YES";
    }
  return 0;
}

#include<stdio.h>
int main()
{
    int n, l;
    int a[100], b[100];
    while(scanf("%d%d", &n, &l) != EOF)
    {
        int i, f = 0;
        for(i = 0; i < n; i++)scanf("%d", a + i);
        for(i = 0; i < n; i++)scanf("%d", b + i);
        for(i = 1; i < n; i++)
        {
            if(a[i] - a[i-1] == b[i] - b[i-1]) continue;
            f = 1;
        }
        if(f == 0) printf("YES\n");
        else printf("NO\n");
    }
     return 0;
}

/*input
1 5
2 3
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
#define pb push_back

int main() {
  int n,l;
  cin>>n>>l;
  int a[n],b[n],d1[n],d2[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];

  for(int i=0;i<n-1;i++) {
	d1[i]=a[i+1]-a[i];
	d2[i]=b[i+1]-b[i];

  }
  if(n==1)
  	{if(a[0]==b[0]||a[0]+b[0]==l)
  		return cout<<"YES",0;
  	else
  		return cout<<"NO",0;

  	}

  d1[n-1]=l-a[n-1]+a[0];
  d2[n-1]=l-b[n-1]+b[0];
  sort(d2,d2+n);
  sort(d1,d1+n);
  bool f=1;
  for (int i = 0; i < n; ++i)
  {
  	if(d1[i]!=d2[i])
  		f=0;
  }
  if(f)
  	cout<<"YES";
  else
  	cout<<"NO";

return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	int n, l;
	int x, y;
	cin>>n>>l;
	vector<int> kefa(n), sasha(n);
	cin>>y;
	kefa[0]=y;
	for(int i=1;i<n;i++)
	{
		cin>>kefa[i];
		x=kefa[i];
		kefa[i]-=y;
		y=x;
	}
	kefa[0]+=(l-y);
	cin>>y;
	sasha[0]=y;
	for(int i=1;i<n;i++)
	{
		cin>>sasha[i];
		x=sasha[i];
		sasha[i]-=y;
		y=x;
	}
	sasha[0]+=(l-y);
        bool flag = false;
        int matches = 0;
        for (int i = 0; i < n*2; i++)
        {
            if (kefa[matches]==sasha[i%n])
            {
                matches++;
                if (matches==n-1)
                {
                    flag = true;
                    break;
                }
            }
            else
		    matches = 0;
	}
	if(flag==true)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
int l,n;
cin>>l>>n;
set<int> s1,s2;
int a[l],b[l];
for(int i=0;i<l;i++)
{
 cin>>a[i];
}
for(int i=0;i<l;i++)
{
 cin>>b[i];
}
for(int i=1;i<l;i++)
{
    s1.insert(a[i]-a[i-1]);
}
s1.insert((n-a[l-1])+a[0]);
for(int i=1;i<l;i++)
{
    s2.insert(b[i]-b[i-1]);
}
s2.insert(n-b[l-1]+b[0]);
int flag=0;

set<int>::iterator i=s1.begin();
set<int>::iterator ii=s2.begin();
while(i!=s1.end()&&ii!=s2.end())
{
if(*i!=(*ii))
flag=1;
i++;
ii++;
}
if(flag==1)
cout<<"NO\n";
else
cout<<"YES\n";
	return 0;
}

#include <iostream>
#include <vector>
using namespace std;
int a, b;
int k[1000];
int s[1000];
bool check(vector<int>& p,vector<int>& o){
	for(int i = 0; i<a-1;i++){
		int tmp = 0;
		for(int j = 0;j<a-1;j++){
			if(p[j] == o[(i+j)%(a-1)]){
				tmp += 1;
			}
		}
		if (tmp == a-1){
			return true;
		}
	}
	return false;
}
void putArray(vector <int>& arr, int x[1000]){
	for(int i = 0 ; i < a-1 ; i ++){
		arr.push_back(x[i+1]-x[i]);
	}

}
int main(){
	cin >> a >> b;
	for(int i = 0;i<a;i++) cin >> k[i];
	for(int i = 0;i<a;i++) cin >> s[i];
	vector <int> p;
	vector <int> o;
	putArray( p,k);
	putArray( o,s);
	if(check(p,o)){
		cout << "YES"<<endl;
	} else{
		cout << "NO" << endl;
	}
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n, l;
	map <int, int> m;
	cin >> n >> l;
	vector <int> a(n, 0);
	vector <int> b(n, 0);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> b[i];
	}
	int u = 0;
	while (u < n)
	{
		vector <int> b1;
		int f;
		f = abs(b[0] - a[u]);
		for (int i = 0; i < n; i++)
		{
			b[i] += f;
			if (b[i] > l)
			{
				b[i] -= l;
			}
			//cout << b[i] << ' ';
			b1.push_back(b[i]);
		}
		int g = 0;
		sort(b1.begin(), b1.end());
		for (int i = 0; i < n; i++)
		{
			if (a[i] == b1[i])
			{
				g++;
			}
		}
		if (g == n)
		{
			cout << "YES";
			return 0;
		} else u++;
		//cout << g << endl;
	}
	cout << "NO";
	return 0;
}