#!/usr/bin/env python3
import sys
import random

n = int(sys.argv[1])
max_t = int(sys.argv[2])
max_x = int(sys.argv[3])
random.seed(int(sys.argv[4]))

assert max_t >= n

# choose n unique times between 1 and max_t
if max_t < 2*n:
    times = random.sample(list(range(max_t+1)), k=n)
else:
    times = set()
    while len(times) < n:
        t = random.randint(0,max_t)
        if t not in times:
            times.add(t)
    times = list(times)
random.shuffle(times)

print(n)
for t in times:
    print(t, random.randint(1,max_x))
