#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; typedef vector VI; typedef pair PI; const double EPS=1e-9; int n; const int N = 110; int w[N]; int mat[N][N]; int main(void){ cin >> n; REP(i, 0, n) { int d; cin >> d; int r1 = (i + d) % n; int r2 = (i - d % n + n) % n; mat[r1][i] = 1; mat[r2][i] = 1; } REP(i, 0, n) { cin >> w[i]; w[i] = 1 - w[i]; mat[i][n] = w[i]; } int r = 0; int m = n + 1; REP(c, 0, m) { int r1 = -1; REP(i, r, n) { if (mat[i][c]) { r1 = i; break; } } if (r1 == -1) { continue; } REP(i, 0, m) { swap(mat[r][i], mat[r1][i]); } REP (i, 0, n) { if (i != r && mat[i][c]) { REP(j, c, m) { mat[i][j] ^= mat[r][j]; } } } ++r; } bool ok = 0; if (r >= 1) { REP(i, 0, n) { ok |= mat[r - 1][i]; } ok |= !mat[r - 1][n]; } cout << (ok ? "Yes" : "No") << endl; }