/*
                                                                       ,"
                                                                      ,P
                                                                     ,*
                                                                     */
                                                                     #   ifndef c_
                                                                     char*       y,*g
                                                           ,        na[             32
                                                          ],       *z,*               o,
                                                          *r      ,* nu                [8
                                                          ],      *  ru                 =
                                                          "^"    ,*   po                 =
                                                           "$"   ""   ,*                 q
                                                           ,mu   [1    +                8
                      +                                     1+6   ]    ,*               p
                     ;                                       int   P    ,d             ,
                     J                                        ,/*   \    `
                      :                                        `Ko.  `    `
                      !                                          `ji   `   .
                       `*                                          ta_   -  \
                         *                                           `*/   f ;
                           #                                           define c_
                             /**/                                         #include __FILE__
                                   /*+**/                              #include<string.h>/****...   */
                                            #define D           ;break;default:/*KokoroWoKomete.***..o....oo***/
                                                         typedef/*#*/int Z;typedef unsigned int/**/W;W/*0*/su[256],j;
                                                     #define M(_) for(;m>-1&&m<u;m+=a)if(_(q[m]))break;if(m<0||m>=u)R(0)
                                                #define N(_) O;m>-1&&m<u;m+=a)if(!_(q[m]))break;if (0>m||      u<=m) R(0x0)
                                             typedef/**/ char S;typedef struct _x{W/**/_;Z m,a,h,o,u       ;S       *   x;/**/
                                          struct/**/           _x*y;} X;typedef/*P*/void         T                         /**/;
                                       #include/*'                   */<stdlib.h>                                            /**/
                                     #define/**/                       B   break;                                              /**/
                                   #define/**L    */Q                          if                                          (     /**/
                                 typedef struct/**/_v{                                                         W         _;Z n;   X**x
                                ;struct _v*l,*r;}V;V*v    ,*w                                   ,              *G,         *n,*H,**x;X*
                               L;Z ko,ji,ta=sizeof(X)  ,ge=                                      /*.      `.    "*/          sizeof(X*),
                              GE=sizeof(V);FILE*YU,*ME;X**  s,   *                            t,*l;T*A(    Z/*.  */a)    {R    (calloc(a,
                             1))}Z/**/Ma,ho,u_,Tsu,ka,i_; Z/**/ze(Z a                     ) { R((a>64&&a<  91) ?a+32:a   );}Z  yu(FILE*a){R
                           (fclose(a))}Z/*->*/K,I,k,u,c,h,i,_,Y,U,m,e[9];Z               sa(Z/**/a){R((a>64&&a<91)||(a> 96&&a<123))}Z/**/ki(
                          Z/**/a){R(a>47&&a<58)}Z/**/ga(Z/* */a){;R(sa(a)|| ki           (a))}Z ke(Z a){R((a==32)||(a>8&&a<14))}Z F(T*a){free
                        (a);R(1)}Z/**/ne(S*a,S*b,Z/**/o_)   {R(sprintf(a,b,o_))}       Z  Ne(S*a,Z b){R(fwrite(a,b,01,ME))}T/*9*/se(T*a,T*b,Z
                       o_){memcpy(a,b,o_);}Z yo(S*a,S*b)    {R(printf(a,b))}T zo(    T){Q! (Ma&&L->a>1)&&!(ho&&L->a<2)){Tsu?(L->a>9999999)?Ne(
                     "*a\x20lot*\t",8):ne(mu,"%7d\t",L      ->a)?Ne(mu,8):0:00;Ne(L   ->x,L  ->h);}O(x=&v);*x;){Q(*x)->_==L->_)B x=(*x)->_>L->_
                   ?&((*x)->l):&((*x)->r);}Q*x){w=*x;       O i=h=0;i<w->n;i++){(w->   x[i]-L )?0:(w->x[i]=s_);w->x[i]?0:h++;}Q h>=w->n){Q(w->l)
                  )Q(w->r)){;H=G=w->l;Q(n=G->r)){;O;        n ->r;n=n->r)H=n;H->r=n->   l;n->l =G;n->r=w->r;*x=n;}E{G->r=w->r;*x=G;}}E*x=w->l;E*x
                =w->r;F(w->x);F(w);}}l=L;(L=L->y)?0         : (t=s_);F(l->x);F(l);}Z re  (T){R( atoi(q))}Z ro(T){R(abs(re()))}Z ya(T){O(i=0);i<w->
              n;i++)Q!w->x[i]){w->x[i]=l;R(0)} Q!(s         = (X**)A(ge*2*w->n)))R(1)se(   s,w-> x,w->n*ge);F(w->x);(w->x=s)[w->n]=l;w->n*=2;R(0)}
             W oo(T){O(c=(Z)*(p++)-48);ki(*p)  ;++           p )c=c*10+(Z)*p-48;--p;R(c)}Z  _2(Z/**/a,Z*b,Z*o_,S*n_){m=*b;e[Y=U=0]=0;O p=n_;*p;p++)
            switch(*p){C(94);m=0;C(43)a=01;B  C/*            `  */(36)m=u-01;C( 45)a=-1;B;C  (64)*o_=m;B/**/C(40)Q(U>7))R(0)nu[U++]=p;e[U]=0;B;C(41)
           Q!U)R(0)U--;Q(e[U]>1)){p=nu[U];e[  U++               ]--;}E/**/Q(e[U] ==1)){;p++;  oo();e[U]--;}E{r=p++;Q!ki(*p))R(0)Q(e[U]=oo())<2){e[U]=
         0;}E{p=r-1;U++;}}D;Q(ki(*p))){m+=a   *oo                ();Q(m<0)|| m>=u  )R(0)Y=0;}E Q(strchr("sadiSADI",*p))){Q(Y==-(Z)*p))m+=a;switch(*p)                           {
        C(97)M(sa);B;C(100)M(ki);B;C(105);    M(                  ga);B;C(115 );M(  ke);B;C(65) N(sa);B;C(68)N(ki);B;C(73)N(ga);B;C(83)N(ke)D;B}Y=-(Z)                          *
       p;}E{Q*p==47)Q!*++p)R(0)O(Y-(Z)*p)?    0:                   (m+=a) ;(m> -1&&  m<=u)?q[m]-*p:0;m+=a);Q(m)<0||m>u)R(0)Y=(Z)*p;}B}*b=m;R(1)}Z/**/go(                       T
      ){K++;Q(I>0))O;L?(K-L->m>I):0;zo());    u=                    k;O(c)  =0;  c<2   &&u>0;c++){Q(q[u-1]-13)&&(q[u-1]-10))B--u;}i=i_=0;h=u-1;j=~0;Q(u>0)                    ){
     Q(_2(1,&i,&h ,y))?_2(-1,&h,&i,z)?((h     =h                      -i+1)<  0):  1:    1){Q!ka)R(0)i=0;h=u;}c=h;p=q+i;Q(u_))O;c>0;c--)j=((j>>8)&0xffffffU)^                su
     [(j^(W)ze(*  (p++)))&0xff];E/**/O;c>      0                        ;c--)  j=   ((     j>>8)&0xffffff)^su[(j^(W)*(p++))&0xff];}E{i=h=0;Q!_2(1,&i,&h,y)||!_2             (-
    1,& h,&i,z)   )Q!ka)R(0);i=h=0;}O(w)=       v                         ;(w)   ?(          w->_-j):0;w=(w->_>j)?w->l:w->r);Q(w)){s=w->x;O(c=0);c<w->n;c++){Q*s)Q        (*s
   )-> u==h){p    =(*s)->x+(*s)->o;r=q+/*        ,-====-.                     `                */i;i_=h;Q(u_)){O;i_-->0;)Q ze(*p++)-ze(*r++))B}E/**/O;i_-->0;)Q*p++-*r   ++)
  B/*   */Q(i_    )<0){(*s)->m=K;(*s)->/*      /   88888                            ,--=====-_   */a++;R(0)}}s++;}}Q!(l=(X*)A(ta)))R(1)Q!(l->x=(S*)A(l->h=k)))R(F(l))se(l->
  x,q   ,k);l     ->y=s_;l->a=1;l->m=K/*(     :   8888888                          '  o88888bo==.   `*/;l->o=i;l->u=h;l->_=j;t?(t=(t->y=l)):(L=t=l);Q(I<0&&K>-I) )R(0)O(x=&v);*x;){Q(*x)->_==j
 ){w    =*x;R     (ya())}x=((*x)->_>j)?/*,    '   88888  8                           d888888  8b \     */&((*x)->l):&((     *x)->r);}Q!(*x=w=(V*)A(GE)))R(1)Q!(w->      x=(X**)A(ge*(w->n
 =4)    ))){*     x=s_;R(F(w))}w->_=j;w/*;        86668888                           88888888888  `     */->l=w->r=s_         ;R(ya())}Z/**/to(T){Q!(g=(S*)A(J=256
 ))     )R(1)     O(f)=_=ko=ji=0;;){Q(f<J/*       86666668                           96666888888       */)){Q(c=fread  (   g   +f,1,J-f,YU))<J-f)ko=1;f+=c;}O(_=P=0
 );      _<f;    _=d){P=1;q=o=g+_;O(d)=_;/*`       966666P                            866666668P       */d<f;d++){Q*(       o  )==10){k=++d-_;ji+=go();P=0;B}E Q*o==
 13      ){Q(    ++d<f)){Q*++o==10)d++;k=/*|         ~~~~                              9666666P        >*/d-_;ji+=go(   )  ;   P=0;}B}o++;}Q(P))B}Q(ko))B/**/Q(_>0)){
 o=       g;O   c=0;c<f-_;c++){*o=*(o+_);/*;                                            ~~~~~         */o++;}f-= _;_=    0;    }E{Q!(o=(S*)A(J*2)))R(F(g))se(o,g,f);F(
  g        ); g=o;J*=2;}}Q(f)>_){q=g+_;k=f-_                                                         ;ji+=go();} F(g )   ;R    (ji)}Z main(Z a,S**b){Ma=ho=u_=Tsu=ka=I
  =K       =0;p=r =s_;y=ru;z=po;O(i=1);i<a; i                                                       ++)Q b[i][0 ]==    45     )switch(b[i][1]){C(0)p= *b;B C(117)Ma=1;B
   C      (100)  ho=1;{;}B C(105)u_=0x1;B;C (                                                      +99) Tsu=1;  B;C( 107     ) ka=0x1;B;C(104)C(108)C(  114)C(102)C(115
    )   C(/*  */119)Q b[h=i]  [2])q=&b[i][2];E                                                    {Q( i>a))R(  (yo(         "   %s\40__?\n",b[i])))q=b    [++i];}(b[h][1
     ]==       104)?( I=re(  )):(b[h][1]==108)                                                   ?!( y=q):(   b[          h]     [1]==114)?!(  z=q):(y     =ru)?(z=po)?(
 b[h           ][1]-  102)?  (b[h][1]-115)?ne(                                                 z=( na)/*     */          ,       "^%d",abs(re(  )-01)):     ne(y=na,"^%d"
              ,ro()) :ne(y=na,"^S(sS)%d",ro()):                                              0:  (0)D                R(yo         ("%s?\n",b[i   ]));}E       p?(r=b[i]):
              (p=b[i ]); YU=stdin;ME=stdout;Q p                                                               &&p-*b)Q             !(YU=fopen(    p,"rb"       )))R(yo(/*
             */ "r"  ""  "ead(%s)\n" ,p))Q(r))Q!(                                                           ME                     =fopen((r),     "wb+"       )))R(yu(YU
              ) /*    #    +11737=S*/+yo("writ"  /*                                                       */                        "e(%" "s)"      "\n"        ,r))O(i)
             =        0    ;(j=i)<256;su[i++]=j    )O            h=010;00<h;h                           --                          )(j&  1)?        (j=         (j>>1)^
                       (  (34866<<   4)|(0xedb<<      20          ))):(j>>=1)                        ;v=                            s_;L  =t=        s_;O         ( to()
                          )?fputs(   "out\40o"/*       `*/          "f\40mem"                      ""                               "o"   /*          YU.         ' ]|*/
                          "ry\n",    stderr):0;L;       zo()         );R(yu(                    YU)                                +yu    (            ME           ))}
                          #else/*    8eb96a54 =C:        2004/3                              ,-'                                   me                  !!            */
                         #define      R(_)/*sa `*/        return((                       _/*'                                     */                   ))            ;
                         #define       C(_)/*ge `*/        case(  /*.                */_)                                                               :
                         #/*iA{*/       define/* `*.        `7o*L    */E         else
                          #/*Yz*/         include  /*         `!*/      <stdio.h>
                          /*A*/  #          define   O         for(
                          void*               /* */s_            =0;
                           #/*LL                   "8o             */\
                           endif                     /*.             `--
                            '/  \                       `
                             */