#include <bits/stdc++.h>
using namespace std;
char c[1001];
int a[1001], b[1001], aa[1001], bb[1001];
bool bo[1001];
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  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 = 1; i < n; i++) aa[i] = a[i + 1] - a[i];
  for (int i = 1; i < n; i++) bb[i] = b[i + 1] - b[i];
  aa[n] = a[1] + m - a[n];
  bb[n] = b[1] + m - b[n];
  for (int i = 1; i <= n; i++) aa[i + n] = aa[i];
  for (int i = 1; i <= n; i++)
    if (aa[i] == bb[1]) {
      int j = i, k = 1;
      while (k <= n) {
        j++, k++;
        if (aa[j] != bb[k]) break;
      }
      if (k > n) {
        printf("YES");
        return 0;
      }
    }
  printf("NO");
  return 0;
}
