import sys input = lambda : sys.stdin.readline().rstrip() write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x)) debug = lambda x: sys.stderr.write(x+"\n") YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO) LI = lambda : list(map(int, input().split())) # sys.setrecursionlimit(3*10**5+10) class BaseF2: def __init__(self, vs=None): """vs: list of vecotr in F2 orig[i] : i番目の基底に対応する入力された整数 index[i]: i番目の基底を作るときにinsertした数を復元するために必要なbaseの要素のインデックス """ self.base = [0] self.orig = [0] self.index = [0] if vs is not None: for v in vs: self.insert(v) def dim(self): return len(self.base) def insert(self, v): # 次元が上がったかを返す v0 = v ind = 0 for i,u in enumerate(self.base): if v^u < v: v = v^u ind ^= self.index[i] if v==0: return False ind ^= (1<>i&1: ans.append(l[i-1]) v,ii,jj = l[i-1] jj += 1 ss[jj].append(ii) xx ^= v assert xx==x ll = [] ind = 1000 _a = [0] + a + [0]*10000 for i in range(1, n+1): tmp = ss[i] tmp.sort() p = 0 for k in tmp: for _ in range(k-p): shift(i) p = k xor(0, i) # assert _a[0]==x assert len(ll)<=1000 print(len(ll)) for item in ll: write(" ".join(map(str, item)))