#include <cstdio>
#include <queue>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cstring>

//#define LOG

using namespace std;
struct Figure
{
	int color1, color2;

	Figure(int c1, int c2) : color1(c1), color2(c2) {}
};

#define MAX_COLOR 5
#define BLACK 5

FILE* file, * stdinlog;

const double EPS = 1e-5;
const int dir[] = {1, 0, -1, 0};
const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const int loopPoints[] = {0, 0, 3, 6, 12, 24, 50, 100};

const int Height = 16;
const int Width = 8;

struct Field
{
	int maxLevel;

	Field()
	{
		for (int i = 0; i < Width; ++i)
			for (int j = 0; j < Height; ++j)
				field[i][j] = -1;
		maxLevel = 0;
	}

	Field(Field & rhs)
	{
		for (int i = 0; i < Width; ++i)
			for (int j = 0; j < Height; ++j)
			{
				field[i][j] = rhs.field[i][j];
			}
		maxLevel = rhs.maxLevel;
	}

	void operator = (Field & rhs)
	{
		for (int i = 0; i < Width; ++i)
			for (int j = 0; j < Height; ++j)
			{
				field[i][j] = rhs.field[i][j];
			}
		maxLevel = rhs.maxLevel;
	}

	short field[Width][Height];
	int labels[Width][Height];
	int add(Figure x, int s, int r)
	{
		if (r != 1)
		{
			if (!addOne(s, x.color1))
				return -100500;
			if (!addOne(s + dir[r], x.color2))
				return -100500;
		}
		else
		{
			if (!addOne(s + dir[r], x.color2))
				return -100500;
			if (!addOne(s, x.color1))
				return -100500;
		}
		int ans = 0;
		int tmp = 0;
		int loop = 0;
		while (tmp = Explode())
		{
			ans += tmp;
			++loop;
		}
		ans += loopPoints[min(loop, 7)];
		return ans;
	}

	bool addOne(int s, int color)
	{
		for (int i = 0; i < Height; ++i)
		{
			if (field[s][i] == -1)
			{
				field[s][i] = color;
				return true;
			}
		}
    #ifdef LOG
    fprintf(file, "addOne FAILED: %d\n", s);
    #endif
		return false;
	}

	int _count[300];
	int Explode()
	{
		memset(labels, 0, sizeof(labels));
		int cnt = 1;
		for (int i = 0; i < Width; ++i)
			for (int j = 0; j < Height; ++j)
				if (! labels[i][j])
				{
					_count[cnt] = 0;
					dfs(i, j, cnt);
					cnt++;
				}
		double ans = 0;
		for (int i = 0; i < Width; ++i)
		{
			for (int j = 0; j < Height; ++j)
			{
				if (field[i][j] >= 0 && field[i][j] < 5 && _count[labels[i][j]] >= 4)
				{
					field[i][j] = -1;
					int c = _count[labels[i][j]];
					ans += (c - 1.) / c;
					for (int k = 0; k < 4; ++k)
					{
						int nx = i + dx[k];
						int ny = j + dy[k];
						if (nx >= 0 && ny >= 0 && nx < Width && ny < Height && field[nx][ny] == BLACK)
						{
							field[nx][ny] = -1;
						}
					}
				}
			}
		}
		int points = ans + EPS;
		//if (points == 0) return points;
		throwDown();
		return points;
	}
	void throwDown()
	{
		maxLevel = 0;
		for (int i = 0; i < Width; ++i)
		{
			int cnt = 0;
			for (int j = 0; j < Height; ++j)
			{
				if (field[i][j] != -1)
				{
					field[i][cnt] = field[i][j];
					++cnt;
				}
			}
			if (cnt > maxLevel)
				maxLevel = cnt;
			for (int j = cnt; j < Height; ++j)
			{
				field[i][j] = -1;
			}
		}
	}
	void dfs(int x, int y, int number)
	{
		labels[x][y] = 1;
		_count[number]++;
		for (int i = 0; i < 4; ++i)
		{
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (nx >= 0 && ny >= 0 && nx < Width && ny < Height && !labels[nx][ny] && field[nx][ny] == field[x][y])
			{
				dfs(nx, ny, number);				
			}
		}
		labels[x][y] = number;

	}

	void read(bool check = false)
	{		
		for (int j = Height - 1; j >= 0; --j)
		{
			scanf("\n");
			for (int i = 0; i < Width; ++i)
			{
				char c;
				//scanf("%c", &c);
				cin >> c;
        #ifdef LOG
        fprintf(stdinlog, "%c", c);
        #endif

				int oldcell = field[i][j];

				if (c == '.')
					field[i][j] = -1;
				else if (c == '*')
					field[i][j] = BLACK;
				else
					field[i][j] = c - '1';		

//				if (check)
					//fprintf(file, "CHECK\n");
				/*
				if (check && field[i][j] != oldcell && field[i][j] != BLACK)
				{
					fprintf(file, "ARGGGG!!! [%d %d] %d != %d\n", i, j, field[i][j], oldcell);
				}
				*/
			}      
      #ifdef LOG
      fprintf(stdinlog, "\n");
      #endif
		}
	}
};

struct Move
{
	int s, r, points, maxLevel;
	Move(int s, int r, int points, int maxLevel) : s(s), r(r), points(points), maxLevel(maxLevel) {}
};

struct FigureGenerator
{
	int x0;
	int last;

	FigureGenerator(int x0 = 0): x0(x0), last(x0)
	{		
	}

	int getNext()
	{
		int next = ((__int64(last)) * 17235617 + 4311271) % 87465851;
		int tmp = last;
		last = next;
		return tmp;
	}
};

FigureGenerator generator;

struct MoveFinder
{
#define DEPTH 2

	FigureGenerator g;
	Field f;
	int colors[DEPTH * 2];
	MoveFinder(Field f) : f(f)
	{
		g = generator;
		for (int i = 0; i < DEPTH * 2; ++i)
			colors[i] = g.getNext();
	}

	
	Move findMove(int depth = 0)
	{
		if (depth == DEPTH)
		{
			return Move(0, 0, 0, 0);
		}
		
		Field oldf = f;
		Move bestMove = Move(0, 0, 0, 100500);
		for (int s = 0; s < Width; ++s)
		{			
			for (int r = 0; r < 4; ++r)
			{
				int points = 0;
				if (s == 0 && r == 2 || s == Width - 1 && r == 0)
					continue;

        #ifdef LOG
        for (int i = 0; i < depth; ++i)
          fprintf(file, "  ");
        fprintf(file, "Attempt move s = %d, r = %d\n", s, r);
        #endif

				f = oldf;
				int color1 = colors[depth * 2] % 5;
				int color2 = colors[depth * 2 + 1] % 5;				
				points = f.add(Figure(color1, color2), s, r);
				Move m = findMove(depth + 1);

        
        #ifdef LOG
        for (int i = 0; i < depth; ++i)
          fprintf(file, "  ");
        fprintf(file, " Points: %d, maxLevel: %d, afterMovePoints: %d\n", points, f.maxLevel, m.points);
        #endif
				
				if (points + m.points > bestMove.points || (points + m.points == bestMove.points && f.maxLevel < bestMove.maxLevel))
        {
          #ifdef LOG
          for (int i = 0; i < depth; ++i)
            fprintf(file, "  ");
          fprintf(file, "  Change best move: %d %d, points: %d, bestMove before: %d %d, points: %d\n", s, r, points + m.points, bestMove.s, bestMove.r, bestMove.points);
          #endif

					bestMove = Move(s, r, points + m.points, f.maxLevel);
        }
			}
  	}
    #ifdef LOG
    for (int i = 0; i < depth; ++i)
      fprintf(file, "  ");
    fprintf(file, " Return: %d %d, points: %d\n", bestMove.s, bestMove.r, bestMove.points);
    #endif

		return bestMove;
	}

};

void logg(string s)
{
  

}

int main()
{	
  #ifdef LOG
  file = fopen("log.txt", "w");
  stdinlog = fopen("stdin.txt", "w");
  #endif

	Field ourField, hisField;
	for(int round = 0; ; ++round)
	{
		char str[100];
		scanf("%s", str);
    #ifdef LOG
    fprintf(stdinlog, "%s\n", str);
    #endif
		if(! strcmp(str, "Quit"))
		  break;
		if(! strcmp(str, "Start"))
		{
			int x0;
			scanf("%d", &x0);
			generator = FigureGenerator(x0);
			printf("B[l]ot\n");
			fflush(stdout);
		}
		else if(! strcmp(str, "Move"))
		{
			ourField.read(true);
			//scanf("\n");
			hisField.read();
      //scanf("\n");

			// find move
			MoveFinder finder(ourField);
			Move m = finder.findMove();
			generator.getNext();
			generator.getNext();

			printf("%d %d\n", m.r == 2 ? m.s - 1 : m.s, m.r);
			fflush(stdout);
		}
	}

  #ifdef LOG
  fclose(file);
  fclose(stdinlog);
  #endif

}