#include <bits/stdc++.h>
using namespace std;
template <class T>
T gcd(T a, T b) {
  if (!b) return a;
  return gcd(b, a % b);
}
template <class T>
T power(T a, T b) {
  T res(1);
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
template <class T>
T powerM(T a, T b, T mod) {
  T res(1);
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
const int infi = 2147483647;
const long long infl = 9223372036854775807;
int n, m, k, T, a[1000], b[1000];
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= (n); ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= (n); ++i) scanf("%d", &b[i]);
  int ok(0);
  for (int i = 1; i <= (n); ++i) {
    int ok1(1);
    for (int j = 1; j <= (n - 1); ++j) {
      int k = i + j - 1, l = i + j;
      if (k == n) {
        if (b[j + 1] - b[j] != a[1] + m - a[n]) {
          ok1 = 0;
          break;
        }
        continue;
      }
      if (k > n) k -= n, l -= n;
      if (b[j + 1] - b[j] != a[l] - a[k]) {
        ok1 = 0;
        break;
      }
    }
    if (ok1) {
      ok = 1;
      break;
    }
  }
  if (ok)
    puts("YES");
  else
    puts("NO");
  return 0;
}
