#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[105];
int b[105];
bool flag = 0;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[n + i] = a[i];
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    b[n + i] = b[i];
  }
  for (int i = 1; i <= n; i++) {
    a[i] = ((a[i + 1] - a[i]) % m + m) % m;
  }
  for (int i = 1; i < 2 * n; i++) {
    b[i] = ((b[i + 1] - b[i]) % m + m) % m;
  }
  for (int l = 0; l < n; l++) {
    int now = 1;
    for (int i = 1; i <= n; i++) {
      if (a[i] != b[i + l]) {
        now = 0;
        break;
      }
    }
    if (now) {
      flag = 1;
      break;
    }
  }
  if (flag) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
