/*------------------------------------------------------------
TEAM40
A
235
Target: MSVC9; Platform: Win32; Comment: MS Visual C++ 9
------------------------------------------------------------*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <cassert>

using namespace std;

#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;
}

int 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) {
  board[move.ex][move.ey]=board[move.sx][move.sy];
  board[move.sx][move.sy]=EMPTY;
  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);
}

// _HERE_IT_COMES!!!
// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!!!!! ATACK!!!!!!!!!!!!!!!!!!!!!!!!

#define fr(i,a,b) for ( int i = (a); i <= (b); ++i )
#define fi( a ) for ( int i = 0; i < ( a ); ++i )
#define fj( a ) for ( int j = 0; j < ( a ); ++j )
#define fk( a ) for ( int k = 0; k < ( a ); ++k )
#define clr( a ) memset( ( a ), 0, sizeof( ( a ) ) )
#define pb push_back()
#define mp make_pair
#define all( v ) ( v ).begin(), ( v ).end()

typedef vector < int > vi;
typedef pair  < int, int > pii;

int step = 0;
int a[8][8];

game_move to_move( int x1, int y1, int x2, int y2, bool inv )
{
	if ( inv )
	{
		x1 = 7 - x1;
		x2 = 7 - x2;
	}
	game_move g;
	g.sx = x1;
	g.sy = y1;
	g.ex = x2;
	g.ey = y2;
	return ( g );
}

bool valid( int x, int y ) { return ( x >= 0 && y >= 0 && x < 8 && y < 8 ); }

bool attack( int &x1, int &y1, int &x2, int &y2 )
{
	fi( 4 ) 
	{
		fj( 4 )
			if ( a[i][j] == 1 )
			{
				for ( int dy = 1; dy >= -1; dy -= 2 ) if ( dy != 0 )
				{
					int nx = i + 1;
					int ny = j + dy;
					if ( !valid( nx, ny ) ) continue;
					if ( a[nx][ny] == 3 - 1 )
					{
						x1 = i; y1 = j; x2 = nx; y2 = ny;
						return ( true );
					}
				}				
			}
		fr(j,4,7)
			if ( a[i][j] == 1 )
			{
				for ( int dy = 1; dy >= -1; dy -= 2 ) if ( dy != 0 )
				{
					int nx = i + 1;
					int ny = j + dy;
					if ( !valid( nx, ny ) ) continue;
					if ( a[nx][ny] == 3 - 1 )
					{
						x1 = i; y1 = j; x2 = nx; y2 = ny;
						return ( true );
					}
				}				
			}
	}
	
	
	for ( int i = 7; i >= 4; --i ) fj( 8 )
		if ( a[i][j] == 1 )
		{
			fr(dy,-1,1) if ( dy != 0 )
			{
				int nx = i + 1;
				int ny = j + dy;
				if ( !valid( nx, ny ) ) continue;
				if ( a[nx][ny] == 3 - 1 )
				{
					x1 = i; y1 = j; x2 = nx; y2 = ny;
					return ( true );
				}
			}				
		}

	return ( false );
}

int best[8][8];
pii Q[100 * 100];
pii hod;
int best1;

bool zaebisya(int x, int y, int cnt)
{
   	if ( a[x][y] == 2 ) return ( false );
	if (x == 7)
	{
		best1 = min( cnt, best1 );
		return (true);
	}
    if (best[x][y] <= cnt)
    	return (false);

    fr(dy, -1, 1)
    {
    	int nx = x + 1;
    	int ny = y + dy;
    	if (!valid(nx, ny)) continue;
    	if ( a[nx][ny] == 2 ) continue;
    	if (zaebisya(nx, ny, cnt + 1))
    	{
    		hod = mp(nx, ny);
    		return (true);
    	}
    }
    return (false);
}

int megastep;

bool f(int &X, int &Y)
{
	X = Y = -1;
	fi(8)
		fj(8)
			best[i][j] = 999;

	fi(8)
		fj(8)
			if (a[i][j] == 2)
			{
				int head = 0, tail = 0;
				Q[tail++] = mp(i, j);
				best[i][j] = 0;
				while (head < tail)
				{
					pii p = Q[head++];
					fr(dy, -1, 1)
					{
						int nx = p.first - 1;
						int ny = p.second + dy;
						if (!valid(nx, ny)) continue;
						if (best[nx][ny] > best[p.first][p.second] + 1)
						{
							best[nx][ny] = best[p.first][p.second] + 1;
							Q[tail++] = mp(nx, ny);
						}
					}
				}
			}
	
	int ret = 999;
	pii hod1;
	fi(8)
    	fj(8)
    		if (a[i][j] == 1)
    		{
    			best1 = 999;
    			if (zaebisya(i, j, 0))
    			{
	    			if ( best1 < ret )
	    			{
	    				ret = best1;
	    				X = i;
	    				Y = j;
	    				hod1 = hod;
	    			}	
    			}
			}
	if ( ret < 999 )
	{
		megastep = ret;
		hod = hod1;
		return ( true );
	}

	return (false);
}

bool last_hod( int & x1, int & y1, int & x2, int & y2 )
{
	fj( 8 )
		if ( a[6][j] == 1 )
		{
			fr( dy,-1,1 )
			{
				if ( !valid( 7, j + dy ) ) continue;
				if ( dy != 0 )
				{
					x1 = 6;
					y1 = j;
					x2 = 7;
					y2 = j+dy;
					return ( true );
				}
				else
				{
					if ( a[7][j] != 2 )
					{
						x1 = 6;
						x2 = 7;
						y1 = y2 = j;
						return ( true );
					}
				}
			}
		}
	return ( false );
}

bool twostep( int & fx, int & fy, int & tx, int &ty )
{
	fj( 8 )
		if ( a[1][j] == 2 ) return ( false );
	fj( 8 )
		if ( a[5][j] == 1 )
		{
			fr(dy,-1,1)
			{
				int ny = j + dy;
				if ( !valid( 6, ny ) ) continue;
				if ( a[6][ny] != 0 ) continue;
				int ok = 0;
				fr(dy1,-1,1) if ( dy1 != 0 )
				{
					int ny1 = ny + dy1;
					if ( !valid( 7, ny1 ) ) 
					{
						++ok;
						continue;
					}
					if ( a[7][ny1] != 0 ) continue;
					++ok;

                }
                if ( ok == 2 )
                {
	               	fx = 5;
					fy = j;
					tx = 6;
					ty = j + dy;
					return ( true );                 				
				}

			}
		}
	return ( false );
}


bool boi( int x, int y )
{	
	fr(dy,-1,1) if ( dy != 0 )
	{
		if ( valid( x + 1, y + dy ) )
		{
			if ( a[x+1][y+dy] == 2 )
				return ( true );
		}	
	}
	return ( false );
}

game_move doit()
{	
	int our = color;
	memcpy( a, board, sizeof a );
	if ( our == 2 )
	{
		for ( int i = 0, i1 = 7; i < i1; ++i, --i1 )
		{
			fj( 8 )
			{
				swap( a[i][j], a[i1][j] );
			}
		}	
		fi( 8 ) fj( 8 )
			if ( a[i][j] )
				a[i][j] = 3 - a[i][j];
	}

	int fx, fy, tx, ty;

	if ( last_hod( fx, fy, tx, ty ) )
	{
		return ( to_move( fx, fy, tx, ty, our == 2 ) );
	}
	if ( twostep( fx, fy, tx, ty ) )
	{
		return ( to_move( fx, fy, tx, ty, our == 2 ) );
	}

	megastep = 999;
	int X, Y;
	if (f(X, Y))
	{
		//return ( to_move( X, Y, hod.first, hod.second, our == 2 ) );
		int bestBlack = 8;
		fi( 8 ) fj( 8 )
			if ( a[i][j] == 2 )
				bestBlack = min( bestBlack, i );
		if ( megastep < bestBlack - 1 )
		{
			return ( to_move( X, Y, hod.first, hod.second, our == 2 ) );			
		}
	}
	

	if ( attack( fx, fy, tx, ty ) )
	{
		return ( to_move( fx, fy, tx, ty, our == 2 ) );		
	}

	if ( megastep < 999 )
	{
		return ( to_move( X, Y, hod.first, hod.second, our == 2 ) );			
	}

	//string s1[] = {"b2a3", "d2c3", "f2e3", "h2g3"};
	if (step == 1)
	{
		return ( to_move( 1, 1, 2, 0, our == 2 ) );
	}
	if (step == 2)
	{
		return ( to_move( 1, 3, 2, 2, our == 2 ) );
	}
	if (step == 3)
	{
		return ( to_move( 1, 5, 2, 4, our == 2 ) );
	}
	if (step == 4)
	{
		return ( to_move( 1, 7, 2, 6, our == 2 ) );
	}


	fi( 8 )
		fj( 8 )
		{
			if ( a[i][j] == 1 )
			{
				int ii = i;
				while ( ii < 8 && a[ii][j] == 1 ) ++ii;
				--ii; 
				fr(dy,0,0)
				{
					int nx = ii + 1;
					int ny = j + dy;
					if ( !valid( nx, ny ) ) continue;
					if ( a[nx][ny] == 0 && !boi( nx, ny ) )
					{
						return ( to_move( ii, j, nx, ny, our == 2 ) );
					}

				}
			}
		}


	fi( 8 )
		fj( 8 )
		{
			if ( a[i][j] == 1 )
			{
				fr(dy,0,0)
				{
					int nx = i + 1;
					int ny = j + dy;
					if ( !valid( nx, ny ) ) continue;
					if ( a[nx][ny] == 0 && !boi( nx, ny ) )
					{
						return ( to_move( i, j, nx, ny, our == 2 ) );
					}

				}
			}
		}

	fi( 8 )
		fj( 8 )
		{
			if ( a[i][j] == 1 )
			{
				fr(dy,-1,1)
				{
					int nx = i + 1;
					int ny = j + dy;
					if ( !valid( nx, ny ) && !boi( nx, ny ) ) continue;
					if ( a[nx][ny] == 0 )
					{
						return ( to_move( i, j, nx, ny, our == 2 ) );
					}

				}
			}
		}	



	for ( int i = 7; i >= 0; --i )
		fj( 8 )
		{
			if ( a[i][j] == 1 )
			{
				int ii = i;
				while ( ii < 8 && a[ii][j] == 1 ) ++ii; 
				--ii;
				fr(dy,0,0)
				{
					int nx = ii + 1;
					int ny = j + dy;
					if ( !valid( nx, ny ) ) continue;
					if ( a[nx][ny] == 0 )
					{
						return ( to_move( ii, j, nx, ny, our == 2 ) );
					}

				}
			}
		}


	for ( int i = 7; i >= 0; --i )
	fj( 8 )
		{
			if ( a[i][j] == 1 )
			{
				fr(dy,0,0)
				{
					int nx = i + 1;
					int ny = j + dy;
					if ( !valid( nx, ny ) ) continue;
					if ( a[nx][ny] == 0 )
					{
						return ( to_move( i, j, nx, ny, our == 2 ) );
					}

				}
			}
		}

	for ( int i = 7; i >= 0; --i )
		fj( 8 )
		{
			if ( a[i][j] == 1 )
			{
				fr(dy,-1,1)
				{
					int nx = i + 1;
					int ny = j + dy;
					if ( !valid( nx, ny ) ) continue;
					if ( a[nx][ny] == 0 )
					{
						return ( to_move( i, j, nx, ny, our == 2 ) );
					}

				}
			}
		}	
//	return ( to_move( 1, 0, 2, 0, 0 ) );
//	assert( true );
}

void think(char *str) {
  
	++step;
  	game_move move = doit();
  	sprintf(str,"%c%d%c%d",move.sy+'a',move.sx+1,move.ey+'a',move.ex+1);
  	make_move(move);
}

int main() {
  srand(time(0));
  init();
  for(;;) {
    char str[100];
    gets(str);
    if(!strcmp(str,"Name")) {
      // Request for the bot name
      printf("Battle Frogs!\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;
}
