N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) D=dict() for i in range(N): D[B[i]]=i ANS=[] for i in range(N): v=D.get(A[i],-1) if v>=0: ANS.append((1,i+1,v+1)) A[i]=0 while max(A)>min(B): X=A.index(max(A)) Y=B.index(min(B)) ANS.append((1,X+1,Y+1)) ANS.append((2,X+1,Y+1)) ANS.append((1,X+1,Y+1)) A[X]^=B[Y] B[Y]^=A[X] A[X]^=B[Y] if (A[X] in B)and(A[X]>0): for j in range(N): if A[X]==B[j]: ANS.append((2,X+1,j+1)) B[j]=0 print(A,B) D=dict() for i in range(N): D[B[i]]=i for i in range(N): v=D.get(A[i],-1) if v>=0: ANS.append((1,i+1,v+1)) A[i]=0 print(len(ANS)) for i in range(len(ANS)): print(*ANS[i])