#!/usr/bin/env python3
import sys
from math import gcd
from fractions import Fraction
import random


MAX_N = 2*10**5
MAX_E = 10**5
MAX_X = int(float(sys.argv[1]))

steps = []
totstep = 0
q = 1
while totstep + q <= MAX_X:
    for p in range(q+1):
        if gcd(p, q) == 1:
            if totstep + p + q > MAX_X:
                break
            totstep += p + q
            steps.append((p, q))
    q += 1

ratio = int(sys.argv[2])
    

steps.sort(key = lambda f: Fraction(f[0], f[1]))
(x, y) = (1, totstep)
base_pts = [(x, y)]
for (p, q) in steps:
    x += q
    y -= p
    base_pts.append((x, y))
steps.pop()
for (p, q) in reversed(steps):
    x += p
    y -= q
    base_pts.append((x, y))

random.shuffle(base_pts)
arr = sorted(base_pts[0:MAX_N])
print(MAX_N)
for e in arr: print(e[0], e[1])
print(MAX_E)
ee = MAX_N
for i in range(MAX_E):
    if i%ratio == 0:
        if random.randint(0, 1) == 0:
            t = random.randint(1, 10**2)
            xx = random.randint(1, 10**8)
            yy = random.randint(1, 10**8)
            print('c', t, xx, yy)
        else:
            # makes internal points more likely
            i1 = random.randint(0, MAX_N - 1 - i//2)
            i2 = random.randint(0, MAX_N - 1 - i//2)
            i3 = random.randint(0, MAX_N - 1 - i//2)
            while i1 == i2: i2 = random.randint(0, MAX_N - 1 - i//2)
            while i1 == i3 and i2 == i3: i3 = random.randint(0, MAX_N - 1 - i//2)
            f1 = random.uniform(0, 1)
            f2 = random.uniform(0, 1 - f1)
            f3 = random.uniform(0, 1 - f1 - f2)
            if random.randint(0, 1) == 0: f1 *= 1.1
            print('c', 1, min(MAX_X, int(arr[i1][0]*f1 + arr[i2][0]*f2 + arr[i3][0]*f3)), min(MAX_X, int(arr[i1][1]*f1 + arr[i2][1]*f2 + arr[i3][1]*f3)))
    else:
        print('q', ee)
        ee -= 1
