#include using namespace std; int main() { int n; cin >> n; static bitset<123> a[100]; for (int i = 0; i < n; i++) { int d; cin >> d; int x = (i + d) % n; int y = (i - d) % n; if (y < 0) y += n; a[x][i] = true; a[y][i] = true; } for (int i = 0; i < n; i++) { int w; cin >> w; a[i][n] = !w; } int r = 0; for (int k = 0; k < n; k++) { int p = -1; for (int i = r; i < n; i++) { if (a[i][k]) { p = i; break; } } if (p == -1) { continue; } swap(a[r], a[p]); for (int i = 0; i < n; i++) { if (i == r) { continue; } if (a[i][k]) { a[i] ^= a[r]; } } r++; } for (int i = r; i < n; i++) { if (a[i][n] != 0) { puts("No"); return 0; } } puts("Yes"); }