local l = io.read("*n")
local fact = {}
local c = 1
while c * 2 <= l do
  table.insert(fact, c)
  c = c * 2
end
local ret = {}
local n = #fact + 1
for i = 1, n - 1 do
  table.insert(ret, {i, i + 1, 0})
  table.insert(ret, {i, i + 1, fact[i]})
end
local rem = l - 1 - (2 * fact[#fact] - 1)
local offset = 2 * fact[#fact]
for i = #fact, 1, -1 do
  if fact[i] <= rem then
    table.insert(ret, {i, n, offset})
    rem = rem - fact[i]
    offset = offset + fact[i]
  end
end
print(n .. " " .. #ret)
for i = 1, #ret do
  print(ret[i][1] .. " " .. ret[i][2] .. " " .. ret[i][3])
end
