char*p;t[99];n;d;f(char*x){int c=*x,l=4;for(*x=32;l--;*x-c||f(x))x+="\xf7\x08\x02\xff"[l];n+=d||(*x=c);}main(z,j,k){for(read(0,t,t);k;--z)for(j=9;j--;)for(k=0,p=t;*++p;n=d=0)j?p[9]-32||(p[9]=*p,*p=32):*p/62&1?f(p),k+=d=n>3,f(p):0;printf("%s\n%d chains",t,-z);}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).