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(2): if len(X[i])>=2: k=X[i][0] l=X[i][1] ANS1=[0]*N ANS2=[0]*N ANS1[k]=1 ANS1[l]=2 ANS2[k]=2 ANS2[l]=1 now=1 LL=[1,2] for i in range(N): if ANS1[i]==0: ANS1[i]=now now+=1 while now in LL: now+=1 now=1 for i in range(N): if ANS2[i]==0: ANS2[i]=now now+=1 while now in LL: now+=1 print(*ANS1) print(*ANS2) exit() from itertools import permutations from collections import Counter if N<=8: 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] 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) exit() B=[(A[i],i) for i in range(N)] B.sort() for i in range(N-1): if B[i+1][0]-B[i][0]<=N-1: IND=[i,i+1] sa=B[i+1][0]-B[i][0] break k,l=IND ANS1=[0]*N ANS2=[0]*N if sa==0: ANS1[k]=1 ANS1[l]=2 ANS2[k]=2 ANS2[l]=1 LL=[1,2] else: ANS1[k]=1 ANS1[l]=1+sa ANS2[k]=1+sa ANS2[l]=1 LL=[1,1+sa] now=1 for i in range(N): if ANS1[i]==0: ANS1[i]=now now+=1 while now in LL: now+=1 now=1 for i in range(N): if ANS2[i]==0: ANS2[i]=now now+=1 while now in LL: now+=1 print(*ANS1) print(*ANS2) exit()