/*------------------------------------------------------------
TEAM12
A
238
Target: MSVC9; Platform: Win32; Comment: MS Visual C++ 9
------------------------------------------------------------*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <queue>

#include <cassert>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>

using namespace std;

#define Eo(x) 
//{ cerr << #x << " = " << (x) << endl; }

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;

const int SIZE = 8;
#define MAX_MOVES (BOARD_SIZE*2*3)
const int DEPTH = 4;
const int DEPTH_SECOND = 4;

enum {WHITE=0,BLACK=1,EMPTY=2,};

struct pos{
	char x,y;
	pos(){}
	pos(int x_, int y_):x(x_),y(y_){}
	bool operator<(const pos& p)const{
		if (y != p.y) return y < p.y;
		return x < p.x;
	}
};


int zzz = 0;

struct game_move {
	pos from;
	pos to;
	game_move(){}
	game_move(int fx, int fy, int tx, int ty):from(fx,fy),to(tx,ty){}
	string tostring() const{
		string res("a1a1");
		res[0] += from.x;
		res[1] += from.y;
		res[2] += to.x;
		res[3] += to.y;
		return res;
	}
	void rev(){
		from.y = 7-from.y;
		to.y = 7-to.y;
	}
	bool operator<(const game_move& m)const{
		if (from.x != m.from.x) return from.x < m.from.x;
		if (from.y != m.from.y) return from.y < m.from.y;
		if (to.x != m.to.x) return to.x < m.to.x;
		if (to.y != m.to.y) return to.y < m.to.y;
		return false;
	}
};

ostream& operator<<(ostream& os, const game_move& m){
	return (os << m.tostring());
}

int bitcnt[1 << SIZE];
inline int bit(int k){
	return (1 << k);
}

const int H_CONST = 1;
const int COUNT_CONST = 20;
const int WIN_CONST = 1024*1024;
const int DEF_CONST = 1;
const int ADD_CONST = 1024;

int defense[1 << SIZE];

typedef pair<game_move,int> pgi;

struct bd{
	char a[SIZE];
	bd(){}

	int cnt;
	int def;
	int last;

	bool operator<(const bd& b)const{
		for (int i = 0; i < SIZE; i++)
			if (a[i] != b.a[i])
				return a[i] < b.a[i];
		return false;
	}

	void init(){
		a[0] = a[1] = bit(SIZE)-1;
		for (int i = 2; i < SIZE; i++)
			a[i] = 0;
		cnt = 16;
		last = 1;
	}
	int estimate()const{
		if (a[SIZE-1] != 0) return WIN_CONST;
		return cnt*COUNT_CONST+last*last*H_CONST;// + 0*def*DEF_CONST;
	}
	void remove(int x, int y){
		if (a[y]&bit(x)){
			a[y] ^= bit(x);
			cnt--;
		}
	}
	void set(int x, int y){
		if (!(a[y]&bit(x))){
			a[y] |= bit(x);
			cnt++;
			last = max(last,y);
		}
	}
	bool has(int x, int y) const{
		return ((a[y] & bit(x)) != 0);
	}
};

struct board{
	bd a[2];
	void init(){
		a[0].init();
		a[1].init();
	}
	int estimate(){
		if (a[0].a[SIZE-1]) return WIN_CONST;
		if (a[1].a[SIZE-1]) return -WIN_CONST;
		return a[0].estimate()-a[1].estimate();
	}

	bool cangoto(int x, int y, bool tasty) const{
		if (x < 0 || x >= SIZE || y < 0 || y >= SIZE) return false;
		if (!tasty && a[1].has(x,7-y)) return false;
		return !a[0].has(x,y);
	}

	bool operator<(const board& b)const{
		if (a[0] < b.a[0] || b.a[0] < a[0]) return a[0] < b.a[0];
		return a[1] < b.a[1];
	}

	pgi getbestmove(int depth, int prevbest, bool save) ;
};

typedef pair<pair<int,board>,game_move> pvm;
vector<pvm> all;

	pgi board::getbestmove(int depth, int prevbest, bool save) {
		int cur = estimate();
		if (cur == WIN_CONST) return pgi(game_move(-1,-1,-1,-1),cur);
		if (cur == -WIN_CONST) return pgi(game_move(-1,-1,-1,-1),cur);
		if (depth == 0) return pgi(game_move(-1,-1,-1,-1), cur);
		//assert(depth > 0);
		int bestprofit = -inf;
		game_move bestmove(-1,-1,-1,-1);

		bool could = false;
		bool any = false;

		for (int i = 0; i < SIZE; i++) if (a[0].a[i]){
			for (int j = 0; j < SIZE; j++) if (a[0].a[i] & bit(j)){
				for (int d = -1; d <= 1; d++) if (cangoto(j+d,i+1,d!=0)){
					any = true;
					board next_board;
					next_board.a[0] = a[1];
					next_board.a[1] = a[0];
					next_board.a[1].remove(j,i);
					next_board.a[1].set(j+d,i+1);
					next_board.a[0].remove(j+d,7-i-1);

					
					int profit = -next_board.getbestmove(depth-1,bestprofit,save).second;

					if (save && depth == DEPTH){
						game_move next_move(j,i,j+d,i+1);
						all.push_back(pvm(pair<int,board>(bestprofit,next_board),next_move));
					}

					if (-profit < prevbest){
						zzz++;
						game_move next_move(j,i,j+d,i+1);
						bestprofit = profit;
						bestmove = next_move;
						return pgi(bestmove,bestprofit);
					}
//					if (profit == WIN_CONST) profit += (depth+1)*1000;
					//assert(abs(profit) <= WIN_CONST);
					if (i+1 == SIZE-1) could = true;
					if (profit > bestprofit || bestmove.from.x < 0){
						game_move next_move(j,i,j+d,i+1);
						bestprofit = profit;
						bestmove = next_move;
					}
				}
			}
		}

		return pgi(bestmove,bestprofit);
	}


int ourcolor = BLACK;
int enemycolor = WHITE;

inline int opcolor(int who){
	return (who == WHITE) ? BLACK : WHITE;
}

game_move parse_move(const string& move){
	//assert(move.size() == 4);
		return game_move(move[0]-'a',
    		move[1]-'1',
    		move[2]-'a',
    		move[3]-'1');	
}                                        

void make_move(const game_move& m, char who, board& b) {
	//assert(b.a[who].has(m.from.x,m.from.y));
	b.a[1^who].remove(m.to.x,7-m.to.y);
	b.a[who].remove(m.from.x,m.from.y);
	b.a[who].set(m.to.x,m.to.y);
}

game_move think(board& b){
	all.clear();
	pgi best = b.getbestmove(DEPTH,-inf,true);
	sort(all.begin(),all.end());
	int bestprofit = -inf;
	game_move m(-1,-1,-1,-1);
	for (int i = 0; i < all.size(); i++){
		pgi z = all[i].first.second.getbestmove(DEPTH_SECOND,bestprofit,false);
		if (-z.second > bestprofit){
			bestprofit = -z.second;
			m = all[i].second;
		}
	}
	return m;
}

char buf[128];

int main() {
//freopen("log.txt","w",stderr);
	for (int i = 0; i < bit(SIZE); i++)
		for (int j = 0; j < SIZE; j++)
			if (!(bit(j)&i))
				bitcnt[i|bit(j)] = bitcnt[i] + 1;

	for (int i = 0; i < bit(SIZE); i++){
		int mask = 0;
		for (int j = 0; j < SIZE; j++){
			for (int d = -1; d <= 1; d+=2){
				if (j+d >= 0 && j+d < SIZE){
					mask |= bit(j+d);
				}
			}
		}
		defense[i] = bitcnt[mask];
	}
	board b;
	b.init();
  for(;;) {
    gets(buf);
    string command(buf);
    if(command == "Name") {
      // Request for the bot name
      cout << "NSU1 Bot" << endl;
    } else if(command == "Quit"){
      // Game is over
      break;
    } else {
//    	Eo(2);
    	if (command == "Start"){
    		ourcolor = WHITE;
    		enemycolor = BLACK;
    	} else {
//    	Eo(1);
    	    // Enemy's move
    	    game_move move = parse_move(command);
    	    if (ourcolor == WHITE)
	    	    move.rev();
	  //  	Eo("enemy move");
	        make_move(move,1,b);
	//    	Eo("~enemy move");
        }
    	game_move ourmove = think(b);
	//    	Eo("our move");
	    	{
	    	string str = ourmove.tostring();
  //  		Eo(str);
    	}
    	make_move(ourmove,0,b);
//	    	Eo("~our move");
    	if (ourcolor == BLACK)
    		ourmove.rev();
    	string str = ourmove.tostring();
//    	Eo(str);
	    cout << str << endl;
    }
  }
  Eo(zzz);
  return 0;
}
