a = vector(2^13, n, -1)
u = 1

{
	t = 1;
	for (k=0, oo,
		r = t;
		while (i=floor(r),
			if (i<=#a && a[i]==-1,
				a[i] = k;
				while (a[u]>=0,
					print (u " " a[u]);
					if (u++>#a,
						break (3);
					);
				);
			);
			r/=2
		);
		t*=3;
		while (floor(t)>#a,
			t/=2;
		);
	);
}

quit