/*------------------------------------------------------------
TEAM44
A
233
Target: MSVC9; Platform: Win32; Comment: MS Visual C++ 9
------------------------------------------------------------*/
#include <iostream>
#include <vector>
#include <ctime>
#include <algorithm>


using namespace std;


typedef int _board[8][8];

_board boards[2], deck;
bool black;
vector<int> poss;


const int d[] = {1, -1, 0};


void move_pawn(_board deck, int bx, int by, int ex, int ey)
{
	deck[ex][ey] = deck[bx][by];
	deck[bx][by] = -1;	
}


void inv(int & x)
{
	x = 7 - x;
}


bool good(int x)
{
	return x >= 0 && x < 8;
}


bool can_beat(int bx, int by, int ex, int ey)
{
	return good(bx) && good(by) && good(ex) && good(ey) && deck[bx][by] == 0 && deck[ex][ey] == 1;
}


bool can_move(_board deck, int bx, int by, int ex, int ey)
{
	return good(bx) && good(by) && good(ex) && good(ey) && deck[bx][by] == 0 && deck[ex][ey] != 0 && (ey != by || deck[ex][ey] == -1);
}


void print_move(int bx, int by, int ex, int ey)
{	
	if(black)
	{
		inv(bx);
		inv(by);
		inv(ex);
		inv(ey);
	}
	printf("%c%c%c%c\n", bx + 'a', by + '1', ex + 'a', ey + '1');
}


const int pawn_cost = 1000;
const int cost_dist[8] = {1, 4, 7, 8, 20, 200, 5000, 10000000};
const int protect[8]  = {0, 0, 0, 0, 50, 500, 5000, 0};
const int attack[8] = {-50, -50, -50, -50, -50, -250, -5000, 0};
const int fail = 10000000;

struct move
{
	int cost, i,j,k;
	move(int cost = 0, int i = 0, int j = 0, int k = 0): cost(cost), i(i), j(j), k(k) {}
	bool operator < (const move & m) const
	{
		return cost > m.cost;
	}
};

int calc_pos(int k){
	int ans = 0;
	_board &deck = boards[k];
	for (int i=0; i<8; ++i){
		for (int j=0; j<8; ++j){
			if (deck[i][j] == 0)
			{
				ans += pawn_cost;
				ans += cost_dist[i];
				for(int k = std::max(j-1, 0); k <= std::min(j+1, 7); k++)
				{
					if (i < 7 && k != j && deck[i+1][k] == 1)
					{
						ans += attack[i];		
				//		break;
					}
				}
				for(int k = std::max(j-1, 0); k <= std::min(j+1, 7); k++)
				{
					if (i > 0 && k != j && deck[i-1][k] == 0)
						ans += protect[i];
				}
			}    		
		}	
	}
	return ans;
}


int rec(int depth, int board_num, bool print)
{
	if (depth == 0)
		return calc_pos(board_num) - calc_pos(board_num ^ 1);
	int tmp1, tmp2;
	int besti = -1, bestj, bestk;

	int ans = -1000000000;
	move ar[48];
	int cnt = 0;

	_board &our = boards[board_num], &enemy = boards[board_num ^ 1];
	for (int j = 0; j < 8; j++)
		if (our[7][j] == 0)
			return (depth+2) * fail;	

	for (int i = 0; i < 8; i++)
		for(int j = 0; j < 8; j++)
		{
			if (our[i][j] == 0)
			{
				for(int k = j-1; k <= j + 1; k++)
					if (can_move(our, i, j, i+1, k))
					{
						tmp1 = our[i+1][k];
						tmp2 = enemy[6-i][7-k];
						move_pawn(our, i,j, i+1, k);
						move_pawn(enemy, 7-i, 7-j, 6-i, 7-k);

						ar[cnt++] = move(-rec(std::min(0, depth - 1), board_num ^ 1, false), i, j, k);

						move_pawn(our, i+1,k, i, j);
						move_pawn(enemy, 6-i, 7-k, 7-i, 7-j);
						our[i+1][k] = tmp1;
						enemy[6-i][7-k] = tmp2;						
					}
			}
		}
	if (cnt == 0)
		return calc_pos(board_num) - calc_pos(board_num ^ 1) - fail*depth;
	std::sort(ar, ar+cnt);
	if (depth <= 1)
	{
		return ar[0].cost;
	}

	for(int t = 0; t < std::min(8, cnt); t++)
	{
		int i = ar[t].i, j = ar[t].j, k = ar[t].k;
   		tmp1 = our[i+1][k];
   		tmp2 = enemy[6-i][7-k];
   		move_pawn(our, i,j, i+1, k);
   		move_pawn(enemy, 7-i, 7-j, 6-i, 7-k);

   		int newans = -rec(depth-1, board_num ^ 1, false);
		if (newans > ans)
		{
			ans = newans;
			besti = i; bestj = j; bestk = k;
		}
						

   		move_pawn(our, i+1,k, i, j);
   		move_pawn(enemy, 6-i, 7-k, 7-i, 7-j);
   		our[i+1][k] = tmp1;
   		enemy[6-i][7-k] = tmp2;						

	}



	if (print)                                   
	{
		print_move(bestj, besti, bestk, besti+1);
		move_pawn(deck, bestj, besti, bestk, besti+1);
	}
	return ans;
}


void make_move()
{
	for (int i=0; i<8; ++i){
		for (int j=0; j<8; ++j){
			boards[0][i][j] = deck[j][i];
			boards[1][7-i][7-j] = deck[j][i];
			if (deck[j][i] != -1)
				boards[1][7-i][7-j] = 1 - deck[j][i];
		}
	}
/*	for(int i = 0; i < 8; i++)
	{
		for(int j = 0; j < 8; j++)
		{
			printf("%c", ".WB"[boards[0][i][j]+1]);
		}
		printf("\n");
	}*/

	rec(6, 0, 1);              

}


int main()
{
	srand(time(0));
	memset(deck, -1, sizeof(deck));
	for(int i = 0; i < 8; i++)
		for(int j = 0; j < 2; j++)
			deck[i][j] = 0;
	for(int i = 0; i < 8; i++)
		for(int j = 6; j < 8; j++)
			deck[i][j] = 1;
	bool white = false;
	black = false;
	char s[10];
	while(1)
	{
		gets(s);
		if(s[0] == 'N')
		{
			printf("Evil Dance\n");
			fflush(stdout);
		}
		else
		{
			if(s[0] == 'Q')
			{
				break;				
			}
			else
			{
				if(s[0] == 'S')
				{
					white = true;
					make_move();
				}
				else
				{
					if(!white)
					{
						black = true;
						for(int i = 0; i < 8; i++)
							for(int j = 0; j < 4; j++)
							{
								int t = deck[i][j];
								deck[i][j] = deck[7 - i][7 - j];
								deck[7 - i][7 - j] = t;
							}
						white = true;
						for(int i = 0; i < 8; i++)
							for(int j = 0; j < 8; j++)
								if(deck[i][j] != -1)
									deck[i][j] = 1 - deck[i][j];
					}
                    int bx = s[0] - 'a';
                    int by = s[1] - '1';
                    int ex = s[2] - 'a';
                    int ey = s[3] - '1';
                    if(black)
                    {
                    	inv(bx);
                    	inv(by);
                    	inv(ex);
                    	inv(ey);
                    }
                    move_pawn(deck, bx, by, ex, ey);
                    make_move();
				}
			}
		}
		fflush(stdout);
	}       
}	
