import sys MAX = 500 dp = [0] * MAX ck = [False] * MAX def UF(a): if dp[a] < 0: return a else: dp[a] = UF(dp[a]) return dp[a] def conn(a, b): a = UF(a) b = UF(b) if a == b: return False dp[a] += dp[b] + 1 ck[a] |= ck[b] dp[b] = a return True N = int(input()) D = list(map(int, input().split())) W = list(map(int, input().split())) for i in range(N): dp[i] = -1 if W[i] == 0: dp[i] -= 1 ck[i] = False for i in range(N): a = (i + D[i]) % N b = (i - D[i]) % N if b < 0: b += N if a == b: ck[UF(a)] = True else: conn(a, b) for i in range(N): if dp[i] >= 0: continue if not ck[i] and dp[i] % 2 == 0: print("No") sys.exit() print("Yes")