#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, l;
  cin >> n >> l;
  vector<int> arr1(n), arr2(n);
  for (int i = 0; i < n; i++) cin >> arr1[i];
  for (int i = 0; i < n; i++) cin >> arr2[i];
  arr1.push_back(arr1[0]);
  arr2.push_back(arr2[0]);
  vector<int> d1, d2;
  for (int i = 1; i <= n; i++) {
    if (arr1[i] >= arr1[i - 1])
      d1.push_back(arr1[i] - arr1[i - 1]);
    else
      d1.push_back(l - arr1[i - 1] + arr1[i]);
    if (arr2[i] >= arr2[i - 1])
      d2.push_back(arr2[i] - arr2[i - 1]);
    else
      d2.push_back(l - arr2[i - 1] + arr2[i]);
  }
  for (int i = 0; i < d1.size(); i++) d2.push_back(d2[i]);
  bool flag = false;
  for (int i = 0; i + d1.size() < d2.size(); i++) {
    bool check = true;
    for (int j = i, len = 0; len < d1.size(); j++, len++) {
      if (d2[j] != d1[len]) {
        check = false;
        break;
      }
    }
    if (check) {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
