import sys def input(): return sys.stdin.readline().rstrip() def main(): N = int(input()) *D, = map(int, input().split()) *W, = map(int, input().split()) target = 0 arr = [] for i in range(N): target |= (1-W[i]) << i L = (i-D[i]) % N R = (i+D[i]) % N arr.append((1 << L) | (1 << R)) for i in range(N): ans = None for v in arr: if v & (1 << i): ans = v if ans is not None: if target & (1 << i): target ^= ans arr = [x ^ ans if x & (1 << i) else x for x in arr] print('Yes' if target == 0 else 'No') if __name__ == '__main__': main()