#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 121;
int a[N], b[N], n, L, i, tt;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> L;
  for (i = 1; i <= n; ++i) cin >> a[i];
  for (i = 1; i <= n; ++i) cin >> b[i];
  if (a[1] == 0) {
    for (i = 1; i < n; ++i) a[i] = a[i + 1];
    a[n] = L;
  }
  if (b[1] == 0) {
    for (i = 1; i < n; ++i) b[i] = b[i + 1];
    b[n] = L;
  }
  for (int j = 1; j <= 10000; ++j) {
    for (i = 1; i <= n; ++i) --a[i];
    if (a[1] == 0) {
      for (i = 1; i < n; ++i) a[i] = a[i + 1];
      a[n] = L;
    }
    tt = 0;
    for (i = 1; i <= n; ++i)
      if (a[i] != b[i]) {
        tt = 1;
        break;
      }
    if (!tt) return cout << "YES\n", 0;
  }
  cout << "NO\n";
  return 0;
}
