"""input""" #int-input # input = sys.stdin.readline def II(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(MI()) #str-input def SI(): return input() def MSI(): return input().split() def SI_L(): return list(SI()) def SI_LI(): return list(map(int, SI())) #multiple-input def LLI(n): return [LI() for _ in range(n)] def LSI(n): return [SI() for _ in range(n)] #1-indexを0-indexでinput def MI_1(): return map(lambda x:int(x)-1, input().split()) def TI_1(): return tuple(MI_1()) def LI_1(): return list(MI_1()) from collections import deque,defaultdict,Counter mod = 998244353 class fenwick_tree(): n=1 data=[0 for i in range(n)] def __init__(self,N): self.n=N self.data=[0 for i in range(N)] def add(self,p,x): assert 0<=p0): s+=self.data[r-1] r-=r&-r return s #必ず入っている集合を見つける #必ず以下マン、以上マンを見つける # 上72回まで # その後は8回 n = II() p = [0]*(n+1) cnt = [0]*(n+10) #次どこに向かうかを示しておく for i in range(1,n+1): print(1,i,i) p[i] = II() cnt[p[i]] += 1 ml = 0 for i in range(1,n+1): if cnt[i] == 0: now = i res = [now] while p[now] != -1: now = p[now] res.append(now) l = len(res) if ml <= l: ml = l one = res[:] o = one[0] ans = [one[0],one[1]] for i in range(n-2): print(1,o,ans[-1]) ans.append(II()) print(2,*ans)