import sys input = sys.stdin.readline N=int(input()) A=list(map(int,input().split())) if N==2: x=(A[0]+1)^(A[1]+2) y=(A[0]+2)^(A[1]+1) if x==y: print(1,2) print(2,1) else: print(-1) exit() X=[[] for i in range(4)] for i in range(N): X[A[i]%4].append(i) for i in range(4): if len(X[i])>=2: k=X[i][0] l=X[i][1] ANS1=[0]*N ANS2=[0]*N ANS1[k]=2 ANS1[l]=3 ANS2[k]=3 ANS2[l]=2 now=3 for i in range(N): if ANS1[i]==0: ANS1[i]=now now+=1 now=3 for i in range(N): if ANS2[i]==0: ANS2[i]=now now+=1 print(*ANS1) print(*ANS2) exit() from itertools import permutations from collections import Counter if N<=5: L=list(permutations(range(N))) ANS=[0]*len(L) for i in range(len(L)): xor=0 for j in range(N): xor^=(A[j]+L[i][j]+1) ANS[i]=xor C=Counter(ANS) ans=-1 for c in C: if C[c]>=2: ans=c break if ans==-1: print(ans) exit() IND=[] for i in range(len(L)): if ANS[i]==ans: IND.append(i) AA=[0]*N for i in range(N): AA[i]=L[IND[0]][i]+1 print(*AA) AA=[0]*N for i in range(N): AA[i]=L[IND[1]][i]+1 print(*AA)