#include <bits/stdc++.h>
using namespace std;
bool judge(vector<int> &a, vector<int> &b) {
  for (int(i) = 0; (i) < (int)(a.size()); (i)++) {
    if (a[i] != b[i]) return false;
  }
  return true;
}
int main() {
  int N, L;
  cin >> N >> L;
  vector<int> A(N), B(N);
  for (int(i) = 0; (i) < (int)(N); (i)++) cin >> A[i];
  for (int(i) = 0; (i) < (int)(N); (i)++) cin >> B[i];
  for (int(kai) = 0; (kai) < (int)(N + 1); (kai)++) {
    vector<int> C(N);
    for (int(i) = 0; (i) < (int)(N); (i)++) C[i] = B[(i + kai) % N];
    for (int(i) = 0; (i) < (int)(L * 2); (i)++) {
      for (int(j) = 0; (j) < (int)(C.size()); (j)++) C[j] = (C[j] + 1) % L;
      if (judge(A, C)) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}
