n = int(input()) e = 2 ans = [] m = 2 * n c = 1 while c * c <= m: if m % c == 0: x, y = c, m // c if (x + y) % 2 == 1: l, r = (y - x - 1) // 2, (y + x - 1) // 2 ans.append((1, l + 1, r)) c += 1 while True: if 2**e - 1 > n: break a = [0, 1] while a[-1] - a[-2] < n: a.append(a[-1] + len(a) ** e) j = 0 for i in range(len(a)): while j != len(a) and a[j] < a[i] - n: j += 1 if a[j] == a[i] - n: ans.append((e, j + 1, i)) e += 1 ans.sort() print(len(ans)) for e, j, i in ans: print(e, j, i)