#include #include #include using namespace std; using ll = long long; using ull = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) ll N,L; vector A; vector B; vector S; vector Cnt; vector DistSum; ll minvec(const vector& v){ ll x = v[0]; for(ll a : v) x = min(x,a); return x; } ll dist(ll a, ll b){ if(a > b) swap(a,b); return min(A[b]-A[a],A[a]-A[b]+2*L); } int main(){ cin >> N >> L; A.resize(2*N); rep(i,N) cin >> A[i]; rep(i,N) A[i+N] = A[i] + L; A.push_back(L*2+A[0]); B.resize(2*N); rep(i,2*N) cin >> B[i]; B.push_back(B[0]); S.resize(2*N); rep(i,2*N){ if(abs(B[i+1] - B[i]) % abs(A[i+1] - A[i]) != 0){ cout << "No\n"; return 0; } S[i] = (B[i+1] - B[i]) / (A[i+1] - A[i]); } DistSum.assign(2*N,0); rep(i,2*N) rep(j,2*N) DistSum[i] += dist(i,j); Cnt.assign(2*N+1,0); Cnt[0] = - S[2+N-1]; rep(i,2*N) Cnt[i+1] = Cnt[i] - S[i]; //rep(i,2*N) cout << Cnt[i] << " "; cout << endl; rep(i,N) if(Cnt[i] + Cnt[i+N] != 0){ cout << "No\n"; return 0; } //rep(i,2*N) cout << Cnt[i] << " "; cout << endl; rep(i,2*N) rep(j,2*N) if(Cnt[j] >= 0) B[i] -= Cnt[j] * dist(i,j); //rep(i,2*N) cout << B[i] << " "; cout << endl; rep(i,2*N) if(B[i] < 0){ cout << "No\n"; return 0; } rep(i,2*N-1) if(B[i] != B[i+1]){ cout << "No\n"; return 0; } if(B[0] % L != 0){ cout << "No\n"; return 0; } cout << "Yes\n"; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_inst;