#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  vector<int> k(a, 0);
  vector<int> s(a, 0);
  for (int i = 0; i < a; i++) cin >> k[i];
  for (int i = 0; i < a; i++) cin >> s[i];
  bool res = true;
  for (int i = 0; i < a; i++) {
    res = true;
    int d = s[0] - k[i];
    if (d < 0) d += b;
    for (int j = 1; j < a; j++) {
      if (((k[(i + j) % a] + d) % b) != s[j]) {
        res = false;
        break;
      }
    }
    if (res == true) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
