#include #include #include #include using namespace std; #define REP(i,s,e) for (i = s; i <= e; i++) #define rep(i,n) REP (i,0,(int)(n)-1) #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP (i,(int)(n)-1,0) #define INF (int)1e8 #define MOD (int)(1e9+7) typedef long long ll; int par[100]; int find(int x) { if (par[x] == x) return x; else return par[x] = find(par[x]); } void unite(int x, int y) { par[find(x)] = find(y); } void init(int n) { int i; rep (i,n) par[i] = i; } int main(void) { int i, n; int d[100], w[100]; int cnt[100] {}; cin >> n; rep (i,n) cin >> d[i]; rep (i,n) cin >> w[i]; init(n); rep (i,n) { unite((i+d[i])%n,(i-d[i]+n)%n); } rep (i,n) if ((i+d[i])%n == (i-d[i]+n)%n) cnt[find(i)] = -2; rep (i,n) { int x = find(i); if (cnt[x] < 0) continue; cnt[x] += w[i] == 0; } bool ans = true; rep (i,n) ans &= cnt[i] % 2 == 0; if (ans) cout << "Yes" << endl; else cout << "No" << endl; return 0; }