import sequtils,strutils type unionfindtree[I : static[int]] = array[I,int] proc find(U : unionfindtree; a : int, b :int): bool= var s = a t = b while s != U[s]: s = U[s] while t != U[t]: t = U[t] return s == t proc union(U : var unionfindtree; a : int ; b : int)= if U.find(a,b): return var s = a t = b t2 : int while s != U[s]: s = U[s] while t != U[t]: t2 = U[t] U[t] = s t = t2 U[t] = s proc root(U : unionfindtree, a :int):int= var s = a while s != U[s]: s = U[s] return s var N = stdin.readline.parseInt D = stdin.readline.split.map(parseInt) W = stdin.readline.split.map(parseInt) flag : array[101,bool] B : unionfindtree[101] cnt : array[101,int] for i in 1..N: B[i] = i for i,d in D: var p = (i + d) mod N q = (i - d + 1000 * N) mod N if p == q: flag[p] = true else: B.union(p,q) for n in 1..N: if W[n - 1] == 0: cnt[B.root(n)] += 1 if flag[n]: flag[B.root(n)] = true block answer: for n in 1..N: if cnt[n] mod 2 == 1 and flag[n] == false: echo "No" break answer echo "Yes"