#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(x,N) if(mat[x][x]) ok[uf[x]]=1; FOR(x,N) cin>>y, num[uf[x]]+=y==0; FOR(x,N) if(uf[x]==x && num[x]%2 && ok[x]==0) 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; }