big = 1 000 000
s = 0
S = []
unseen = 0
seen(v) = if (v < big, bittest(s, v), setsearch(S, v))
see(v) = if (v < big, s = bitor(s, 2^v), S = setunion(S, [v])); while (seen(unseen), unseen++)

{
	a = vector(10 000);
	u = 1;
	print ("0 0");

	for (n = 0, oo,
		if (n==0,
				v = 0,

			Mod(unseen, n) == Mod(v, n),
				v = unseen,

				forstep (w = (v%n) + (unseen\n)*n, oo, n,
					if (Mod(w, n+1) == Mod(unseen, n+1),
						v = w;
						break;
					);
				);
		);

		see(v);

		if (v && v <= #a,
			a[v] = n;
			while (a[u],
				print (u " " a[u]);
				if (u++ > #a,
					break (2);
				);
			);
		);
	);
}

quit