n = int(input()) s = 1 << n C = list(map(int, input().split())) L = [0] * s H = [0] * s for i in range(s): L[i], H[i] = map(int, input().split())