class DisjointSet(object): def __init__(self, n): self.parent = list(range(n)) self.rank = [0] * n self.num = n # number of disjoint sets def union(self, x, y): self._link(self.find_set(x), self.find_set(y)) def _link(self, x, y): if x == y: return self.num -= 1 if self.rank[x] > self.rank[y]: self.parent[y] = x else: self.parent[x] = y if self.rank[x] == self.rank[y]: self.rank[y] += 1 def find_set(self, x): xp = self.parent[x] if xp != x: self.parent[x] = self.find_set(xp) return self.parent[x] def read_data(): N = int(input()) Ds = list(map(int, input().split())) Ws = list(map(int, input().split())) return N, Ds, Ws def can_make_all_heads(N, Ds, Ws): djs = DisjointSet(N) same = [] for i, d in enumerate(Ds): a = (i + d) % N b = (i - d) % N djs.union(a, b) if a == b: same.append(a) n_zeros = [0] * N for i, w in enumerate(Ws): root = djs.find_set(i) n_zeros[root] += (1 - w) for s in same: root = djs.find_set(s) n_zeros[root] = 0 for n_zero in n_zeros: if n_zero & 1: return False return True if __name__ == '__main__': N, Ds, Ws = read_data() if can_make_all_heads(N, Ds, Ws): print('Yes') else: print('No')