#include int main() { using namespace std; cin.tie(nullptr)->sync_with_stdio(false); int n, l; cin >> n >> l; vector d(n); for (auto&& e : d) cin >> e; vector a(2 * n, vector(2 * n + 1)); for (int i = 0; i < 2 * n; ++i) for (int j = 0; j < 2 * n; ++j) if (i < n and j < n) a[i][j] = abs(d[i] - d[j]); else if (i < n) a[i][j] = l - a[i][j - n]; else if (j < n) a[i][j] = l - a[i - n][j]; else a[i][j] = a[i - n][j - n]; for (int i = 0; i < 2 * n; ++i) cin >> a[i][2 * n]; int row = 0; for (int col = 0; col < 2 * n; ++col) { for (int i = row + 1; i < 2 * n; ++i) if (a[i][col]) { swap(a[row], a[i]); break; } if (a[row][col] == 0) continue; { auto g = accumulate(begin(a[row]), end(a[row]), 0, [](auto x, auto y) { return gcd(x, y); }); for (auto&& e : a[row]) e /= g; } for (int i = 0; i < 2 * n; ++i) { if (i == row or a[i][col] == 0) continue; auto g = gcd(a[row][col], a[i][col]); auto x = a[row][col] / g; auto y = a[i][col] / g; for (int j = col; j <= 2 * n; ++j) a[i][j] = a[i][j] * x - a[row][j] * y; } ++row; } for (int i = row; i < 2 * n; ++i) if (a[i][2 * n]) { cout << "No\n"; exit(0); } for (int i = 0; i < row; ++i) if (a[i][2 * n] % a[i][i] or a[i][2 * n] / a[i][i] < 0) { cout << "No\n"; exit(0); } cout << "Yes\n"; }