/*------------------------------------------------------------
TEAM02
A
229
Target: MSVC9; Platform: Win32; Comment: MS Visual C++ 9
------------------------------------------------------------*/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>

#define BOARD_SIZE 8
#define MAX_MOVES (BOARD_SIZE*2*3)

enum {EMPTY,WHITE,BLACK};

struct game_move {
  int sx,sy;
  int ex,ey;
  int is_capture;
};

inline int op_color(int color) {
  return color==WHITE ? BLACK : WHITE;
}

char board[BOARD_SIZE][BOARD_SIZE];
int color;


void init() {
  memset(board,EMPTY,sizeof(board));
  for(int i=0;i<BOARD_SIZE;++i) {
    board[0][i]=board[1][i]=WHITE;
    board[BOARD_SIZE-1][i]=board[BOARD_SIZE-2][i]=BLACK;
  }
  color=WHITE;
}

void make_move(game_move &move, int change=1) {
  board[move.ex][move.ey]=board[move.sx][move.sy];
  board[move.sx][move.sy]=EMPTY;
  if (change)
	color=op_color(color);
}

void make_move(char *str) {
  char sy,ey;
  int sx,ex;
  sscanf(str,"%c%d%c%d",&sy,&sx,&ey,&ex);
  game_move move={sx-1,sy-'a',ex-1,ey-'a',board[ex-1][ey-'a']!=EMPTY};
  make_move(move);
}

int gen_moves(game_move *moves) {
  int cnt=0;
  for(int i=0;i<BOARD_SIZE;++i) {
    for(int j=0;j<BOARD_SIZE;++j) {
      if(board[i][j]==color) {
        for(int dj=-1;dj<=1;++dj) {
          int ni=i+(color==WHITE ? 1 : -1);
          int nj=j+dj;
          if(ni>=0 && ni<BOARD_SIZE && nj>=0 && nj<BOARD_SIZE &&
             board[ni][nj]!=color && (dj || board[ni][nj]==EMPTY)) {
            game_move move={i,j,ni,nj,board[ni][nj]!=EMPTY};
            moves[cnt++]=move;
          }
        }
      }
    }
  }
  return cnt;
}

//var rec
int rcolor;
int rmove;
int X1,Y1,X2,Y2;
int stop_move = 4;
const double inf = 1e20;
const double eps = 1e-8;
char ver[20]="SB5";
//double one[11]={0.0, 4.05, 6.0, 8.0, 9.0, 10.0, 50.0, 1e10};//1
double one[11]={0.0, 4.0, 7.0, 9.0, 10.0, 10.5, 50.0, 1e10};
double two[11]={0.0, 4.0, 7.0, 9.0, 10.0, 10.5, 50.0, 1e10};
//double two[11]={0.0, 4.05, 6.0, 8.0, 9.0, 10.0, 50.0, 1e10};//3
//double two[11]={0.0, 4.05, 6.0, 8.0, 9.0, 10.0, 50.0, 1e10};//2
//double two[11]={1.0, 2.0, 3.0, 4.0, 5.0, 50.0, 10000.0, 1e9};//1


double func()
{
	int i,j,cnt=0;
	double r1 = .0, r2 = .0;
	int c1[BOARD_SIZE]={0};
	int c2[BOARD_SIZE]={0};
	for (i=0;i<BOARD_SIZE;i++)
	{
		for (j=0;j<BOARD_SIZE;j++)
		{
			if (board[i][j]==color)
			{
				c1[i]++;
				if (color==WHITE)
					r1 += one[i];
				else r1 += one[7-i];
				cnt++;
			}
			else if (board[i][j]==op_color(color))
			{
				c2[i]++;
				if (color==WHITE)
					r2 += two[7-i];
				else r2 += two[i];
			}
		}
	}
	double res;
	res = r1 - r2;
	return res;
}
double rec(double par_val)
{
	if (rmove==stop_move)
		return func();

	int x1,y1,x2,y2;
	double extr_val=-inf;
	for(int i=0;i<BOARD_SIZE;++i) 
	{
		for(int j=0;j<BOARD_SIZE;++j) 
		{
			if(board[i][j]==rcolor) //my
			{
				for(int dj=-1;dj<=1;++dj) 
				{
					int ni=i+(rcolor==WHITE ? 1 : -1);
					int	nj=j+dj;
					if (ni>=0 && ni<BOARD_SIZE && nj>=0 && nj<BOARD_SIZE &&
					board[ni][nj]!=rcolor && (dj || board[ni][nj]==EMPTY)) 
					{
						//exist available moves
						game_move move={i,j,ni,nj,board[ni][nj]!=EMPTY};
						
						char ts = board[i][j];
						char te = board[ni][nj];
						make_move(move,0);
						rmove++;
						rcolor = op_color(rcolor);
						double fval = rec(extr_val);
						rcolor = op_color(rcolor);
						rmove--;
						board[i][j] = ts;
						board[ni][nj] = te;

						//relax
						if (extr_val==-inf)
						{
							x1 = i;
							y1 = j;
							x2 = ni;
							y2 = nj;
							extr_val = fval;
						}
						else
						{
							if (rmove & 1)//enemy move
							{
								if (fval<extr_val || (fabs(fval-extr_val)<=eps && !(rand()%8)))
								{
									extr_val = fval;
									x1 = i;
									y1 = j;
									x2 = ni;
									y2 = nj;
								}
							}
							else//out move
							{
								if (fval>extr_val || (fabs(fval-extr_val)<=eps && !(rand()%8)))
								{
									extr_val = fval;
									x1 = i;
									y1 = j;
									x2 = ni;
									y2 = nj;
								}
							}
						}
						//need other ways?
						if (par_val==-inf)
							continue;

						if ( (rmove & 1)==1 && extr_val<par_val)//enemy move
							return extr_val;
						if ((rmove & 1)==0 && rmove>0 && extr_val>par_val)//our move
							return extr_val;
					}	
				}
			}
		}
	}
	if (rmove==0)
	{
		X1 = x1;
		Y1 = y1;
		X2 = x2;
		Y2 = y2;
	}
	return extr_val;
}
void think(char *str) 
{
	game_move moves[MAX_MOVES];
	int cnt=gen_moves(moves);
	int cntwin = 0,i,j, all=0;
	for (i=0;i<BOARD_SIZE;i++)
	{
		for (j=0;j<BOARD_SIZE;++j)
		{
			if (board[i][j]!=EMPTY)
				all++;
		}
	}
	if (all<=10)
		stop_move = 6;
	else if (all<=20)
		stop_move = 5;
	else stop_move = 4;
	
	for (i=0;i<cnt;i++)
	{
		if ( (color==WHITE && moves[i].ex==7) || (color==BLACK && moves[i].ex==0))
		{
			game_move move = moves[i];
			sprintf(str,"%c%d%c%d",move.sy+'a',move.sx+1,move.ey+'a',move.ex+1);
			make_move(move);
			return;
		}
	}

	rmove = 0;
	rcolor = color;
	double tmp = rec(-inf);
	game_move move={X1,Y1,X2,Y2,board[X2][Y2]!=EMPTY};
	sprintf(str,"%c%d%c%d",move.sy+'a',move.sx+1,move.ey+'a',move.ex+1);
	make_move(move);
}

int main() {
  srand((unsigned)time(0));
  init();
  for(;;) {
    char str[100];
    gets(str);
    if(!strcmp(str,"Name")) {
      // Request for the bot name
      printf("Vyatka SU\n");
      fflush(stdout);
    }
    else if(!strcmp(str,"Quit")) {
      // Game is over
      break;
    }
    else {
      if(strcmp(str,"Start")) {
        // Enemy's move
        make_move(str);
      }
      // Our move
      think(str);
      printf("%s\n",str);
      fflush(stdout);
    }
  }
  return 0;
}
