#include<stdio.h>/*6/2/2000*/
                  int                       b[65536],x,z
               ,r,                        u,v,p,q,o,c,l,s,i;
            int                   e(    ){p^=(o=getchar());if(
          +o ==              +  EOF )p^=EOF;if((++u&1023)==00)/*
        E! */  {           fputc ( 46,stderr);}return o;}void/*SY
       ! */  d(        int w ){  v ++ ; q^=(w&=255);putchar(w);}int
      j /*  */    ;   void  k   ( int t  ){for(;t;t--){x=(x+1)&65535
     ;if(  !(   --   z) ){ b[   x ]=  e   ();z++;}}}int g(int t){for(
    ;+ t  >=  z;b   [(  x +(    z ++) )&65535]=e());return b[(x+t+(1<<
   16 )) &+ 65535  ];;}void     f (){d(r);d(r>>8);for(;r;r--)d(g(-r));}
  int /**/  main( int a){;       for(i=x=u=v=p=q=r=0;i<65536;b[i++]=00);
 if   (a>1 ){for (i=e();i-       EOF ;i=e()){if((j=e())==EOF)break;l=i|(
     j<<8);i=0;if(l&(1 <<         15  )){s=l|(-1<<16);r=e();j=e();l=r|(j<<8)
     ;for(;i<l;i++){d(b[(          x+i)%(1<<16)]=b[(x+i+s+(1<<16))&(     (1<<
     16)-1)]);}}else{for(           ;i< l;d(b[(x+i++)&65535]=e()           ))
     ;} x=(x+l)&65535;}if(              q   ^i)fputs("Checks"             /*
    */  "um\40failed. \n\0             ",  stderr);}else{b              [0
     ]  =e();z=1;for( c=g(0            );c-EOF;c=g(0)){i=  0;for     (s=-5
     ;  + s>- 32767;s -=1){             if(g(s)==c){for(l =1  ;l   <-s;l++
        ) {if  (g(s+l  )-g              (l))break; }if (   l  >i ){i=l;j=s;
        }  }}  if(i>5  )                    {if(   r)f  (    )  ;d(j);d  (+
        j  >>  8);d(i                               );d (i>>8);k(i);}/*  /
           */   else{k(                             1);if(++r>32766 )f
                ( );} }if(                       r)f();d(p);}u--;  /*
                   */   return            fprintf   (stderr,"" \
                            "\n%d/%d\n",v,u            )  ;}