import sys INF = float('inf') #10**20,2**63,float('inf') MOD = 10**9 + 7 MOD2 = 998244353 #from collections import defaultdict def solve(): def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LC(): return list(input()) def IC(): return [int(c) for c in input()] def MI(): return map(int, sys.stdin.readline().split()) N = II() E = LI() flag = False for bit3 in range(3**N): P = [0] * 3 Label = [] # 10進から8進へ if (bit3 == 0): Label.append(0) while bit3: bit3, R = divmod(bit3, 3) Label.append(R) if(len(Label)