#include <stdio.h>
#include <time.h>
#include <cassert>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <deque>

using namespace std;

const string BOTNAME = "T3h 1";

struct random
{
	long long current;
	int next()
	{
		int ret = current % 5 + 1;
		current = (current * 17235617LL + 4311271LL) % 87465851LL;
		return ret;
	}
};

const int blackBallsBonus[7] = {0, 3, 6, 12, 24, 50, 100};
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
const int fieldWidth = 8;
const int fieldHeight = 16;

struct field
{
	int r[fieldHeight][fieldWidth], rs[fieldHeight][fieldWidth];

	void readField()
	{
		char *tmp = new char[fieldWidth + 2];
		for (int i = 0; i < fieldHeight; i++)
		{
			scanf("%s", tmp);
			for (int j = 0; j < fieldWidth; j++)
			{
				if (tmp[j] == '*')
					tmp[j] = '0';
				if (tmp[j] >= '0' && tmp[j] <= '5')
					r[i][j] = tmp[j] - '0';
				else
					r[i][j] = -1;
			}

		}
		delete[] tmp;
	}

	void print()
	{
		for (int i = 0; i < fieldHeight; i++, printf("\n"))
			for (int j = 0; j < fieldWidth; j++)
			{
				if (r[i][j] == -1)
					printf(".");
				else
					printf("%d", r[i][j]);
			}
		printf("\n");
	}

	void saveState()
	{
		memcpy(rs, r, sizeof(r));
	}

	void restoreState()
	{
		memcpy(r, rs, sizeof(r));
	}

	int used[fieldHeight][fieldWidth];
	int stepDFS(int row, int column, int x)
	{
		if (r[row][column] == -1)
			return 0;

		used[row][column] = x;

		int result = 1;

		for (int i = 0; i < 4; i++)
		{
			int nextRow = row + dy[i];
			int nextColumn = column + dx[i];
			if (nextRow >= 0 && nextRow < fieldHeight && nextColumn >= 0 && nextColumn < fieldWidth)
				if (used[nextRow][nextColumn] == 0 && r[nextRow][nextColumn] == r[row][column])
					result += stepDFS(nextRow, nextColumn, x);
		}

		return result;
	}
	int blackBombed;
	int stepDFS2(int row, int column, int x)
	{
		if (r[row][column] == 0)
		{
			r[row][column] = -1;
			blackBombed++;
			return 0;
		}

		r[row][column] = -1;

		int result = 1;

		for (int i = 0; i < 4; i++)
		{
			int nextRow = row + dy[i];
			int nextColumn = column + dx[i];
			if (nextRow >= 0 && nextRow < fieldHeight && nextColumn >= 0 && nextColumn < fieldWidth)
				if (used[nextRow][nextColumn] == x || (used[nextRow][nextColumn] == 0 && r[nextRow][nextColumn] == 0))
					result += stepDFS(nextRow, nextColumn, x);
		}

		return result;
	}

	int bonusPoints;

	pair<int, int> step()
	{
		pair<int, int> result = make_pair(0, 0);

		blackBombed = 0;
		bonusPoints = 0;

		memset(used, 0, sizeof(used));
		for (int i = 0; i < fieldHeight; i++)
			for (int j = 0; j < fieldWidth; j++)
				if (used[i][j] == 0)
				{
					int x = i * fieldWidth + j + 1;
					int count = stepDFS(i, j, x);
					if (count >= 4)
					{
						count = stepDFS2(i, j, x);
						result.first += count;
						result.second++;
					}
					else if (count == 3)
						bonusPoints += 4;
					else if (count == 2)
						bonusPoints += 2;
				}

		deque<int> free;
		for (int i = 0; i < fieldWidth; i++)
		{
			free.clear();
			for (int j = fieldHeight - 1; j >= 0; j--)
			{
				if (r[j][i] == -1)
					free.push_back(j);
				else
				{
					if (!free.empty())
					{
						swap(r[j][i], r[free.front()][i]);
						free.pop_front();
					}
				}
			}
		}

		return result;
	}

	bool drop(int ball1, int ball2, int position, int rotate)
	{
		int width = 1, height = 1;
		if (rotate == 0 || rotate == 2)
			width = 2;
		else
			height = 2;

		//swap(ball1, ball2);
		if (rotate >= 2)
		{
			swap(ball1, ball2);
			rotate -= 2;
		}

		if (position < 0 || position + width > fieldWidth)
			return false;
		
		int row = 0;
		while (row < fieldHeight)
		{
			if (r[row][position] != -1)
				break;
			if (width == 2 && r[row][position + 1] != -1)
				break;
			row++;
		}
		
		row--;

		if (row - height < 0)
			return false;

		if (width == 2)
		{
			r[row][position] = ball1;
			r[row][position + 1] = ball2;
		}
		else
		{
			r[row - 1][position] = ball1;
			r[row][position] = ball2;
		}

		return true;
	}
	
	pair<int, int> getScore()
	{
		/*
		int width = 1, height = 1;
		if (rotate == 0 || rotate == 2)
			width = 2;
		else
			height = 2;

		//swap(ball1, ball2);
		if (rotate >= 2)
		{
			swap(ball1, ball2);
			rotate -= 2;
		}

		if (position < 0 || position + width > fieldWidth)
			return make_pair(-10000, -1);
		
		int row = 0;
		while (row < fieldHeight)
		{
			if (r[row][position] != -1)
				break;
			if (width == 2 && r[row][position + 1] != -1)
				break;
			row++;
		}
		
		row--;

		if (row - height < 0)
			return make_pair(-1, -1);

		saveState();*/

		/*
		if (width == 2)
		{
			r[row][position] = ball1;
			r[row][position + 1] = ball2;
		}
		else
		{
			r[row - 1][position] = ball1;
			r[row][position] = ball2;
		}*/

		//print();
		int stepNumber = 0, score = 0;
		while (true)
		{
			blackBombed = 0;
			bonusPoints = 0;
			pair<int, int> bomb = step();
			//print();
			score += bonusPoints;
			if (bomb.first == 0)
				break;
			score += bomb.first + 2 * blackBombed + bomb.first - bomb.second - 2 + blackBallsBonus[stepNumber];
			stepNumber = min(stepNumber + 1, 6);
		}

		int currentHeight = 0;
		for (currentHeight = 0; currentHeight < fieldHeight; currentHeight++)
		{
			bool ok = true;
			for (int j = 0; j < fieldWidth && ok; j++)
				ok = r[currentHeight][j] == -1;
			if (!ok)
				break;
		}

		//restoreState();

		return make_pair(score, currentHeight);
	}
};

random balls;
field player, enemy;

int moveMaxPosition, moveMaxRotate;
pair<int, int> moveMaxScore;

int curDepth;
vector< pair< pair<int, int>, pair<int, int> > > movesDepth[2];
bool weCan[8][4];

vector< int > ballsOrder;
vector< pair<int, int> > moveOrder;

void moveGo(int k)
{
	if (k == 0)
	{
		player.saveState();

		pair<int, int> score = make_pair(0, 0);

		for (int i = 0; i < moveOrder.size(); i++)
			if (!player.drop(ballsOrder[2 * i], ballsOrder[2 * i + 1], moveOrder[i].first, moveOrder[i].second))
			{
				player.restoreState();
				return;
			}
			else
			{
				pair<int, int> scoreTemp = player.getScore();
				score.second = scoreTemp.second;
				score.first += scoreTemp.first;
			}

		//pair<int, int> score = player.getScore();
			/*
		if (moveMaxScore < score)
		{
			moveMaxPosition = moveOrder[0].first;
			moveMaxRotate = moveOrder[0].second;
			moveMaxScore = score;
		}*/

		movesDepth[curDepth].push_back( make_pair(score, make_pair(moveOrder[0].first, moveOrder[0].second)) );

		player.restoreState();
		return;
	}

	for (int i = 0; i < 8; i++)
		for (int j = 0; j < 4; j++)
		{
			if (curDepth == 1)
			{
				if (k == 1 || weCan[i][j])
				{
					moveOrder.push_back( make_pair(i, j) );
					moveGo(k - 1);
					moveOrder.pop_back();
				}
			}
			else
			{
				moveOrder.push_back( make_pair(i, j) );
				moveGo(k - 1);
				moveOrder.pop_back();
			}
		}

	/*
	pair<int, int> score = player.getScore(ball1, ball2, i, j);
	if (maxScore < score)
	{
		maxPosition = i;
		maxRotate = j;
		maxScore = score;
	}*/
}

const int DEPTH = 2;

void move()
{
	player.readField();
	enemy.readField();

	int ball1 = balls.next();
	int ball2 = balls.next();

	long long ballsCurrent = balls.current;

	ballsOrder.clear();
	ballsOrder.push_back(ball1);
	ballsOrder.push_back(ball2);
	for (int i = 0; i < DEPTH - 1; i++)
	{
		ball1 = balls.next();
		ball2 = balls.next();
		ballsOrder.push_back(ball1);
		ballsOrder.push_back(ball2);
	}

	balls.current = ballsCurrent;

	moveMaxPosition = 0, moveMaxRotate = 0;
	moveMaxScore = make_pair(-2, -100);

	movesDepth[0].clear();
	movesDepth[1].clear();
	curDepth = 0; moveGo(1); 
	sort(movesDepth[0].begin(), movesDepth[0].end()); reverse(movesDepth[0].begin(), movesDepth[0].end());

	memset(weCan, 0, sizeof(weCan));
	const int MAGIC = 10;
	int magic = min(MAGIC, (int)movesDepth[0].size());
	for (int i = 0; i < magic; i++)
		weCan[movesDepth[0][i].second.first][movesDepth[0][i].second.second] = true;
	curDepth = 1; moveGo(2); 
	sort(movesDepth[1].begin(), movesDepth[1].end()); reverse(movesDepth[1].begin(), movesDepth[1].end());

	int last = 0;
	while (last < movesDepth[1].size() - 1)
	{
		if (movesDepth[1][last + 1].first != movesDepth[1][last].first)
			break;
		last++;
	}

	int mega = rand() % (last + 1);
	//mega = 0;

	moveMaxPosition = movesDepth[1][mega].second.first;
	moveMaxRotate = movesDepth[1][mega].second.second;

	/*
	for (int i = 0; i < 8; i++)
		for (int j = 0; j < 4; j++)
		{
			player.saveState();
			if (player.drop(ball1, ball2, i, j))
			{
				pair<int, int> score = player.getScore();
				if (moveMaxScore < score)
				{
					moveMaxPosition = i;
					moveMaxRotate = j;
					moveMaxScore = score;
				}
			}
			player.restoreState();
		}*/

	/*
	static int movecc = 0;
	movecc++;
	if (movecc == 8)
	{
		freopen("output.txt", "w", stdout);
		player.print();
		printf("BALLS = %d %d\n", ball1, ball2);
		printf("MOVE = %d %d SCORE = %d %d\n", maxPosition, maxRotate, maxScore.first, maxScore.second);
		fclose(stdout);
	}*/

	//assert(maxPosition >= 0 && maxPosition < 8);
	//assert(maxRotate >= 0 && maxRotate < 4);
	printf("%d %d\n", moveMaxPosition, moveMaxRotate);

	fflush(stdout);
}

void start()
{
	scanf("%lld", &balls.current);
	printf("%s\n", BOTNAME.c_str());
	fflush(stdout);
}

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	/*
	balls.current = 123456789LL;
	for (int i = 0; i < 10; i++)
	{
		int a = balls.next();
		int b = balls.next();
		printf("%d %d\n", a, b);
	}
	return 0;*/
	srand(time(0));
	char *tmp = new char[100];
	while (true)
	{
		scanf("%s", tmp);
		if (tmp[0] == 'S')
			start();
		else if (tmp[0] == 'M')
			move();
		else
			break;
	}
	delete[] tmp;
	return 0;
}