/*------------------------------------------------------------
TEAM03
A
238
Target: MSVC9; Platform: Win32; Comment: MS Visual C++ 9
------------------------------------------------------------*/
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
using namespace std;

const int BOARD_SIZE= 8;
enum {EMPTY,WHITE,BLACK};

struct peshk
{
	int line;
	int colum;
};

struct hod
{
	peshk from;
	peshk to;
};

int board[BOARD_SIZE+1][BOARD_SIZE+1];
bool invert;
vector<peshk> win7, luse,  win6, todie, other, o45;

const hod go();

void make_move(hod &move) 
{
	board[move.to.line][move.to.colum]= board[move.from.line][move.from.colum];
	board[move.from.line][move.from.colum]= EMPTY;
}

void prot(const string & data)
{
	hod hd;
	char sc,ec;
	int sl,el;
	sscanf(data.c_str(),"%c%d%c%d",&sc,&sl,&ec,&el);
	if (invert)
	{
		hd.from.line= BOARD_SIZE-sl+1;
		hd.from.colum= sc-'a'+1;
		hd.to.line=  BOARD_SIZE-el+1;
		hd.to.colum= ec-'a'+1;
	}
	else
	{
		hd.from.line= sl;
		hd.from.colum= sc-'a'+1;
		hd.to.line= el;
		hd.to.colum= ec-'a'+1;
	}
	make_move(hd);
}

void iam()
{
	hod res;
	res= go();
	make_move(res);
	if (invert)
	{
		res.from.line= BOARD_SIZE-res.from.line+1;
		res.to.line= BOARD_SIZE-res.to.line+1;
	}
	cout << (char)(res.from.colum+'a'-1) << res.from.line << (char)(res.to.colum+'a'-1) << res.to.line << endl;
}

const peshk gpeshk(const int l, const int c)
{
	peshk r;
	r.line= l;
	r.colum= c;
	return r;
}
const hod ghod(const peshk from, const peshk to)
{
	hod r;
	r.from= from;
	r.to= to;
	return r;
}

const bool valid6(const int c)
{
	if (board[7][c]==EMPTY  && ( c+1>8 || board[8][c+1]==EMPTY ) && ( c-1<=0 || board[8][c-1]==EMPTY ) )
		return true;
	if (c+1<=8 && (board[7][c+1]!=WHITE && ( c+2>8 || board[8][c+2]==EMPTY ) && ( c<=0 || board[8][c]==EMPTY )) )
		return true;
	if (c-1>=1 && (board[7][c-1]==EMPTY  && ( c-2<=0 || board[8][c-2]==EMPTY ) && ( c<=0 || board[8][c]==EMPTY ) ))
		return true;
	return false;
}

const bool validr(int c)
{
	if (c-1>=1 && board[2][c-1]==BLACK)
		return true;
	if (c+1<=8 && board[2][c+1]==BLACK)
		return true;
	return false; 
}


const peshk gen_validr(int c)
{
	peshk r;
	r.line= 2;
	if (c-1>=1 && board[2][c-1]==BLACK)
		r.colum= c-1;
	if (c+1<=8 && board[2][c+1]==BLACK)
		r.colum= c+1;
	return r; 
}
const peshk gvalid6(const int c)
{
	peshk r;
	r.line= 7;
	if (board[7][c]==EMPTY  && ( c+1>8 || board[8][c+1]==EMPTY ) && ( c-1<=0 || board[8][c-1]==EMPTY ) )
		r.colum= c;
	if (c+1<=8 && (board[7][c+1]!=WHITE && ( c+2>8 || board[8][c+2]==EMPTY ) && ( c<=0 || board[8][c]==EMPTY )) )
		r.colum= c+1;
	if (c-1>=1 && (board[7][c-1]==EMPTY  && ( c-2<=0 || board[8][c-2]==EMPTY ) && ( c<=0 || board[8][c]==EMPTY ) ))
		r.colum= c-1;
	return r;
}

const bool isbl(const int l, const int c)
{
	if (l<1 || l>8 || c<1 || c>8 )
		return false;
	return board[l][c]== BLACK;
}

const bool isem(const int l, const int c)
{
	if (l<1 || l>8 || c<1 || c>8 )
		return false;
	return board[l][c]== EMPTY;
}

const bool nirub(const int l, const int c)
{
	if (l<1 || l>8 || c<1 || c>8 )
		return false;
	return isbl(l+1, c+1) || isbl(l+1, c-1);
}


const bool cmp(const peshk &a, const peshk &b)
{
	return a.line<b.line;
}

const hod go()
{
	hod res;
	int i, j, k;
	win7.resize(0);
	luse.resize(0);
	win6.resize(0);
	other.resize(0);
	todie.resize(0);
	o45.resize(0);
	for(i=1; i<=8; i++)
		for(j=1; j<=8; j++)
			if (board[i][j]== WHITE)
			{
				if (i==7)
				{
					win7.push_back(gpeshk(i, j));
				}
				else if (i==6 && valid6(j))
				{
					win6.push_back(gpeshk(i, j));
				}
				else if (i==1 && validr(j))
				{
					luse.push_back(gpeshk(i, j));
				}
				else
				{
					if ( isbl(i+1, j+1) || isbl(i+1, j-1) )
						todie.push_back(gpeshk(i, j));						
					else
						other.push_back(gpeshk(i, j));
				}
			}
	if (luse.size()>0)
	{
		return ghod(luse[0], gen_validr(luse[0].colum));		 	
	}
	else if (win7.size()>0)
	{
		if (win7[0].colum!=1)
			return ghod(win7[0], gpeshk(8, win7[0].colum-1));
		else
			return ghod(win7[0], gpeshk(8, win7[0].colum+1));
	}
	else if (win6.size()>0)
	{
		return ghod(win6[0], gvalid6(win6[0].colum)); 
	}
	else if (todie.size()>0)
	{
		i= todie[0].line;
		j= todie[0].colum;
		if (isbl(i+1, j+1) && !isbl(i+2, j+2) && !isbl(i+2, j))
			return ghod(todie[0], gpeshk(i+1, j+1));
		if (isbl(i+1, j-1) && !isbl(i+2, j-2) && !isbl(i+2, j))
			return ghod(todie[0], gpeshk(i+1, j-1));
		
		if (isem(i+1, j+1) && !isbl(i+2, j+2) && !isbl(i+2, j))
			return ghod(todie[0], gpeshk(i+1, j+1));
		if (isem(i+1, j-1) && !isbl(i+2, j-2) && !isbl(i+2, j))
			return ghod(todie[0], gpeshk(i+1, j-1));
		if (isem(i+1, j) && !isbl(i+2, j+1) && !isbl(i+2, j-1))
			return ghod(todie[0], gpeshk(i+1, j+1));

		if (isbl(i+1, j+1))
			return ghod(todie[0], gpeshk(i+1, j+1));
		if (isbl(i+1, j-1))
			return ghod(todie[0], gpeshk(i+1, j-1));
	}
	else
	{
		for(i=0; i<other.size(); i++)
		{
			if (other[i].colum==3  &&  isem(other[i].line+1, other[i].colum+1) && nirub(other[i].line+1, other[i].colum+1))
				return ghod(other[i], gpeshk(other[i].line+1, other[i].colum+1));
			if (other[i].colum==6  && isem(other[i].line+1, other[i].colum-1) && nirub(other[i].line+1, other[i].colum-1))
				return ghod(other[i], gpeshk(other[i].line+1, other[i].colum-1));
			if ((other[i].colum==4 || other[i].colum==5 ) && isem(other[i].line+1, other[i].colum))
				o45.push_back(other[i]);

		}
		if (o45.size()>0)
		{
			sort(o45.begin(), o45.end(), cmp);
			if (isem(other[0].line+1, other[0].colum))
				return  ghod(other[0], gpeshk(other[0].line+1, other[0].colum));
		}
		for(i=0; i<other.size(); i++)
		{
			if (nirub(other[i].line+1, other[i].colum))
				return ghod(other[i], gpeshk(other[i].line+1, other[i].colum));
			if (nirub(other[i].line+1, other[i].colum+1))
				return ghod(other[i], gpeshk(other[i].line+1, other[i].colum+1));
			if (nirub(other[i].line+1, other[i].colum-1))
				return ghod(other[i], gpeshk(other[i].line+1, other[i].colum-1));
		}
		for(i=0; i<other.size(); i++)
		{
			if (isem(other[i].line+1, other[i].colum))
				return ghod(other[i], gpeshk(other[i].line+1, other[i].colum));
			if (isem(other[i].line+1, other[i].colum+1))
				return ghod(other[i], gpeshk(other[i].line+1, other[i].colum+1));
			if (isem(other[i].line+1, other[i].colum-1))
				return ghod(other[i], gpeshk(other[i].line+1, other[i].colum-1));
		}
	}
}

int main()
{
	int i, j, k;
	string cmd, result;
	for(i=1; i<=BOARD_SIZE; i++)
		for(j=1; j<=BOARD_SIZE; j++)
			board[i][j]= EMPTY;
	for(i=1; i<=BOARD_SIZE; i++)
	{
		board[1][i]= board[2][i]= WHITE;
		board[7][i]= board[8][i]= BLACK;
	}
	win7.reserve(BOARD_SIZE*2);
	luse.reserve(BOARD_SIZE*2);
	win6.reserve(BOARD_SIZE*2);
	other.reserve(BOARD_SIZE*2);
	todie.reserve(BOARD_SIZE*2);
	invert= true;
	for(;;)
	{
		cin>> cmd;
		if (cmd=="Name")
		{
			cout << "BEDA" << endl;
		}
		else if (cmd=="Quit")
		{
			break;
		}
		else
		{
			if (cmd=="Start")
			{
				invert= false;
			}
			else
			{
				prot(cmd);
			}
			iam();
			cout.flush();
		}
	}
	return 0;
}
