#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m;
int a[55], b[55];
int aa[55], bb[55];
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) b[i] = read();
  for (int i = 2; i <= n; i++) aa[i] = a[i] - a[i - 1], bb[i] = b[i] - b[i - 1];
  aa[1] = m - a[n] + a[1];
  bb[1] = m - b[n] + b[1];
  for (int j = 0; j < n; j++) {
    bool flag = 0;
    for (int i = 1; i <= n; i++) {
      int x = i, y = x + j;
      if (y > n) y -= n;
      if (aa[x] != bb[y]) {
        flag = 1;
        break;
      }
    }
    if (!flag) {
      printf("YES\n");
      return 0;
    }
  }
  printf("NO\n");
  return 0;
  return 0;
}
