#define\
                                               f     for(
                                              int      b[8
                <<7],                        s= 0+      5,
               #define  p                   printf(      ""
               u[  8]={1,1,1,0,            -1,- 1,-1,     0}
              ,w    [32]={2 ,14,          70, 199 ,799,   2,
             8,     28,90,799,2,2 ,4,10 ,799,4,18,94,348,999
            ,2     ,10,44,220,999,2,2,4,10,999},v[8]={-32 ,0,
           32     ,32,32,0,-32,-32},n[1024],m,x,y,z,i,j,   k,l
         ,r,      t,c; q(){f(x)=j=132           ;x<924&&j  -5;x++
        )if        ((z =b[x])-46)f                     y=0; y<4&&
       j-          5;y ++)f(i)=j=1        ;i      <5&&   j<5;j+=b
      [x          +(u   [y]+v[y])          *+i       ++]  -z?0:1
      );          {;}   return j-           5;}  o     (){ f(x)=!p
     ""     "\n   ")   ;x<s;p  /*       */ "%c ",97     +x++)   );f
     y=    0;y   <s    ;)f x   =      !p"\n%2d ",++    y);x<s;    p/*
     */   "%c " ,b     [(y    +3   )*32+4+x++]  ));}e( ){ if(s<    24)
     f(  i)=    l=     0;i   <2  ;i++)f(j)=0;   j<s;j++){if(b[(      i+
     4) *32    +j      +4   ]-  46)f(k)=(l )=    1023;k>131;b[k       --
      ]=b[    k-   33  ])  ;if (b[(  j+4)*32+    s-i+3]-46)f k=        l=
      1023    ;k   > 131   ;b[ k--]=b[k-32])     ;if(b[33*s-32          *i
      -j+    99   ]- 46) l=10;  if(b[  (s-j+3     )*32+i+4]-             46
     )f      k=  l=  1023;  k>  131; b[k--]       =b[k-1]);;              if
    (l      ){   ;s ++;e();goto h;}} h/**/        :;} main(){              f
   x=      0;   x<  16 << 6;b[x ++   ]=46          );  f/*  */             w[
   31      &    (r =9   + time( 0)                     )]++  ;q             ()
  ;)            {e ();   o();p"\n"                     "\n%%  ")    ;       /*
  */            scanf (" %wc%d"  ,&                   x,   &y  );    b      [(
 y+            3) *    32+(  x|  32            )-    93    ]=  120   ;      f(
 r)           +=x;r       <0;r=   -r       );if(    q(      )) {e(   );     t=
 m=     0     ;f x=        132;   x<              924       ;x  +=    1)    if
 (x     %     32>=           4&&   x%            32         <=  27   &&b[   x]
 ==     46    ){c=            0;f   y=111       ;y          <= 120   ;y+=  9)
 {b[    x]    =y;f             z=0;  z<8;z++){f(            l)=x-(j  =u[z] +
 v[z     ])    ;b[               l]== y;l-=j                );k=b[l  ]-46?5:
  0;f i= 0;    b[l                 +=j]==y                 && i< 5;i ++);;c
  +=w [(  y-    120                  ?15:0)+k+             (  b  [l] -46?4
   :-  1) +i    ];}                    }b[x                      ]=46;if(
   c>t ){t =c   ;m=                                              0;}if(c
    ==t)n[m ++]  =x;                                            }b[n[r%
     m]]=111 ;}}  x--                                          ;y--;f
       i=0;i<5;b[x +(u                                       [y]+v[
         y] )*i++]&=-33)                                ;o();p"\n"
             "game over\n");}