nxt(n) = my (f=factor(n), v=vector(bigomega(f)), i);	\
         for (j=1, #f~, d=digits(f[j,1]); for (k=1, f[j,2], v[i++]=d));	\
		 fromdigits(concat(v))

steps(n) = for (k=0, 8, if (isprime(n), return (k), n=nxt(n))); return (oo)

for (n=2, oo, if (steps(n)==8, print (k++ " " n); if (k==1 000, break)))

quit