#!/usr/bin/env PyPy3 from collections import Counter, defaultdict, deque import itertools import re import math from functools import reduce import operator import bisect import heapq import functools mod=10**9+7 import sys input=sys.stdin.readline n=int(input()) a=list(map(int,input().split())) heapa = [] b=list(map(int,input().split())) heapb = [] for i in range(n): heapa.append([-a[i],i+1]) heapb.append([b[i],i+1]) heapq.heapify(heapa) heapq.heapify(heapb) ans = [] cnt = 0 while True: maa,aind = heapq.heappop(heapa) maa = -maa mib,bind = heapq.heappop(heapb) #print(maa,mib) if maa < mib: break if maa == mib: ans.append([1,aind,bind]) #a[aind-1] ^= b[bind-1] heapq.heappush(heapa,[0,aind]) heapq.heappush(heapb,[maa,bind]) else: xor = maa ^ mib if xor > maa: ans.append([2,aind,bind]) heapq.heappush(heapa,[maa,aind]) heapq.heappush(heapb,[xor,bind]) elif xor < mib: ans.append([1,aind,bind]) heapq.heappush(heapa,[xor,aind]) heapq.heappush(heapb,[mib,bind]) else: ans.append([1,aind,bind]) ans.append([2,aind,bind]) heapq.heappush(heapa,[xor,aind]) heapq.heappush(heapb,[maa,bind]) print(len(ans)) for row in ans: print(*row)