#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[200], b[200];
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  int j;
  for (int i = 0; i < n; i++) {
    for (j = 1; j < n; j++) {
      if ((a[i] - b[0] + m) % m != (a[(j + i) % n] - b[j] + m) % m) break;
    }
    if (j == n) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}
