#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l;
  cin >> n >> l;
  vector<int> s;
  vector<int> k;
  int d;
  for (int i = 0; i < n; i++) {
    cin >> d;
    s.push_back(d);
  }
  for (int i = 0; i < n; i++) {
    cin >> d;
    k.push_back(d);
  }
  int r = 0;
  while (r != l) {
    if (s[0] == k[0]) {
      bool b = 1;
      for (int i = 1; i < n; i++) {
        if (b) {
          if (s[i] != k[i]) {
            b = 0;
          }
        }
      }
      if (b) {
        cout << "YES";
        return 0;
      }
    }
    r++;
    for (int i = 0; i < n; i++) {
      if (k[i] + 1 == l)
        k[i] = 0;
      else
        k[i]++;
    }
    sort(k.begin(), k.end());
  }
  cout << "NO";
}
