#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x>N; FOR(i,N) { cin>>D[i]; x=(i+D[i])%N; y=(i-D[i]+N*1000)%N; mat[x][y]=mat[y][x]=1; uf.unite(x,y); } FOR(i,N) cin>>W[i]; FOR(x,N) if(uf[x]==x) { int ok=0; FOR(y,N) if(uf[y]==x && mat[y][y]==1) ok=1; if(ok) continue; int num=0; FOR(y,N) if(uf[y]==x && W[y]==0) num++; if(num%2) return _P("No\n"); } _P("Yes\n"); } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }