k, q = map (int, raw_input ().split ())
n = 3 ** k
m = n - 1
print n, m
root = 1
size = 0
cur = 2
while cur <= n:
old = root
root = cur
cur += 1
for k in range (size):
print root, cur
cur += 1
print root, old
for k in range (size + 1):
print root, cur
cur += 1
size = cur - 2
print q
for j in range (q):
print 1, 3, n * 5 // 6
aywgcSA9IG1hcCAoaW50LCByYXdfaW5wdXQgKCkuc3BsaXQgKCkpCm4gPSAzICoqIGsKbSA9IG4gLSAxCnByaW50IG4sIG0KCnJvb3QgPSAxCnNpemUgPSAwCmN1ciA9IDIKd2hpbGUgY3VyIDw9IG46CglvbGQgPSByb290Cglyb290ID0gY3VyCgljdXIgKz0gMQoJZm9yIGsgaW4gcmFuZ2UgKHNpemUpOgoJCXByaW50IHJvb3QsIGN1cgoJCWN1ciArPSAxCglwcmludCByb290LCBvbGQKCWZvciBrIGluIHJhbmdlIChzaXplICsgMSk6CgkJcHJpbnQgcm9vdCwgY3VyCgkJY3VyICs9IDEKCXNpemUgPSBjdXIgLSAyCgpwcmludCBxCmZvciBqIGluIHJhbmdlIChxKToKCXByaW50IDEsIDMsIG4gKiA1IC8vIDYK