import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;

alias lread = () => readln.chomp.to!long;
alias aryread = () => readln.split.to!(long[]);

void main()
{
    long l = lread();
    long r;
    long[][] result;
    while (2 ^^ (r + 1) <= l)
    {
        r++;
    }
    long n = r + 1;
    foreach (i; 0 .. n)
    {
        result ~= [i + 1, i + 2, 0];
        result ~= [i + 1, i + 2, 2 ^^ i];
    }

    foreach_reverse (i; 0 .. n)
    {
        if (l - 2 ^^ i >= 2 ^^ r)
        {
            result ~= [r + 1, n, l - 2 ^^ i];
            l -= 2 ^^ i;
        }
    }

    writeln(n, " ", result.length);
    foreach (item; result)
        writeln(item.map!(to!string).join(' '));
}
