#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;

char mas[16][8];
int bonuses[]={0,3,6,12,24,50,100};
int xcur;

struct ress {
	int column, orient;
	int result;
	int height;
	double raz;
	int coolness;
	ress(int c, int ori, int r, int h, double razmer, int cool)
	{
		column = c;
		orient = ori; 
		result = r; 
		height = h;
		raz = razmer;
		coolness = cool;
	}
//	ress()
//	{
//		column=0;
//		orient=0;
//		result=0;
//	}
};

struct Field {
public:
	char state[16][8];

	int top(int col) {
		int i;
		for (i=15;i>=0 && state[i][col]!='.'; --i);
		return i;
	}
};

const double eps = 1e-8;

bool operator< (const ress& r1, const ress& r2) {
	if (r1.result!=r2.result)
		return r1.result<r2.result;
	if (r1.height!=r2.height)
		return r1.height>r2.height;
	if (r1.coolness!=r2.coolness)
		return r1.coolness<r2.coolness;
	return (r2.raz-r1.raz)>eps;
}

bool operator== (const ress& r1, const ress&r2) {
	return (!(r1<r2) && !(r2<r1));
}

bool check (int i, int j, Field& f, char col) {
	if (i<0 || i>=16 || j<0 || j>=8)
		return false;
	if(f.state[i][j]!=col)
		return false;

	return mas[i][j] == 0;
}

int dfs (int xi, int yj, int cur, Field& f) {
	int acc=1;
	mas[xi][yj] = cur;
	if(check(xi-1, yj, f, f.state[xi][yj]))
		acc += dfs(xi-1, yj, cur, f);
	if(check(xi+1, yj, f, f.state[xi][yj]))
		acc += dfs(xi+1, yj, cur, f);
	if(check(xi, yj-1, f, f.state[xi][yj]))
		acc += dfs(xi, yj-1, cur, f);
	if(check(xi, yj+1, f, f.state[xi][yj]))
		acc += dfs(xi, yj+1, cur, f);
	return acc;
}

bool check2 (int i, int j, Field& f) {
	if (i<0 || i>=16 || j<0 || j>=8)
		return false;
	return f.state[i][j] == '*';
}

bool check3 (int i, int j, Field& f, char col) {
	if (i<0 || i>=16 || j<0 || j>=8)
		return false;
	return f.state[i][j]==col;
}

bool check_same_col (int i, int j, Field& f) {
	char col=f.state[i][j];
	if (check3(i-1,j,f,col))
		return true;
	if (check3(i+1,j,f,col))
		return true;
	if (check3(i,j-1,f,col))
		return true;
	if (check3(i,j+1,f,col))
		return true;
	return false;
}

int delcells(int cur, Field& f) {
	const int black_balls = 2;
	int i,j;
	int acc=0;
	for (i=0;i<16;i++)
		for (j=0;j<8;j++) 
			if (mas[i][j]==cur) {
				f.state[i][j]='.';
				if(check2(i-1, j, f)) {
					acc+=black_balls;
					f.state[i-1][j]='.';
				}
				if(check2(i+1, j, f)) {
					acc+=black_balls;
					f.state[i+1][j]='.';
				}
				if(check2(i, j-1, f)) {
					acc+=black_balls;
					f.state[i][j-1];
				}
				if(check2(i, j+1, f)) {
					acc+=black_balls;
					f.state[i][j+1]='.';
				}
			}
	return acc;
}

pair<int,double> hod (Field& f) {
	int i,j;
	int cur=0;
	int balls=0;
	int raz=0;
	int obl=0;
	int curballs;
	vector<int> curs;
	memset(mas, 0, sizeof(mas));
	for (i=0;i<16;i++)
		for (j=0;j<8;j++)
			if (mas[i][j]==0 && f.state[i][j]!='.' && f.state[i][j]!='*') {
				if ((curballs=dfs(i,j,++cur,f)) >= 4) {
					curs.push_back(cur);
					raz+=curballs;
				}
				else {
					raz+=curballs;
				}
			}
	if (curs.empty())
		return make_pair(0,(double)raz/cur);
	for (i=0;i<curs.size();i++) {
		balls += delcells(cur,f);
		balls+=curballs;
		obl++;
	}
	for (i=14; i>=0; --i)
		for (j=0;j<8;j++) {
			int k=i;
			while (k<15 && f.state[k+1][j]=='.') {
				swap(f.state[k][j],f.state[k+1][j]);
				k++;
			}
		}
	return make_pair(balls-obl-2,(double)raz/cur);
}

pair<int,double> calc(Field f) {
	int nlav=0;
	int balls=0;
	pair<int,double> curres;
	while ((curres=hod(f)).first!=0) {
		balls+=curres.first;
		nlav++;
	}
	int bonus=0;
	if (nlav>=7)
		bonus=100;
	else if (nlav==0)
		return make_pair(0,curres.second);
	else
		bonus=bonuses[nlav-1];
	return make_pair(balls+bonus,curres.second);
}

void changex () {
	long long x=xcur*17235617ll + 4311271;
	xcur = (int)x%87465851ll;
}

pair<char, char> getcolors () {
	int col1=xcur%5+1;
	changex();
	int col2=xcur%5+2;
	changex();
	return make_pair(col1, col2);
}

bool make_hod (Field& f, pair<char,char> cols, int orient, int column, int& coolness) {
	coolness=0;
	if (orient == 0 || orient == 2) {
		if (orient==2)
			swap(cols.first,cols.second);
		int row1 = f.top(column);
		int row2 = f.top(column+1);
		if (row1==-1 || row2==-1)
			return false;
		f.state[row1][column]=cols.first;
		f.state[row2][column+1]=cols.second;
		if (check_same_col(row1,column,f)) coolness++;
		if (check_same_col(row2,column+1,f)) coolness++;
	}
	else {
		if (orient==3)
			swap(cols.first,cols.second);
		int row=f.top(column);
		if (row<=0)
			return false;
		f.state[row][column]=cols.second;
		f.state[row-1][column]=cols.first;
		if (check_same_col(row,column,f)) coolness++;
		if (check_same_col(row-1,column,f)) coolness++;
	}
	return true;
}

int calcheight (Field& f) {
	vector<int> hs (8);
	int i;
	for (i=0;i<8;i++)
		hs[i]=f.top(i);
	return (*max_element(hs.begin(),hs.end())-*min_element(hs.begin(),hs.end()));
}

void choose_hod (Field& me, Field& enemy) {
	pair<char, char> colors = getcolors();
	vector<ress> results;
	int i,j;
	pair<int,double> result;
	int height;
	int coolness;
	Field fnew;
	for (j=0;j<7;j++) {
		fnew=me;
		if (!make_hod(fnew, colors, 0, j, coolness))
			continue;
		result=calc(fnew);
		height = calcheight(fnew);
		results.push_back(ress(j,0,result.first,height,result.second,coolness));
		fnew=me;
		if (!make_hod(fnew, colors, 2, j, coolness))
			continue;
		result=calc(fnew);
		height = calcheight(fnew);
		results.push_back(ress(j,2,result.first,height,result.second, coolness));
	}
	for (j=0;j<8;j++) {
		fnew=me;
		if (!make_hod(fnew, colors, 1, j, coolness))
			continue;
		result=calc(fnew);
		height = calcheight(fnew);
		results.push_back(ress(j,1,result.first,height,result.second, coolness));
		fnew=me;
		if (!make_hod(fnew, colors, 3, j, coolness))
			continue;
		result=calc(fnew);
		height = calcheight(fnew);
		results.push_back(ress(j,3,result.first,height,result.second, coolness));
	}
	if (results.empty()) {
		cout << "0 0\n";
		return;
	}
	sort(results.begin(), results.end());
	for (i=results.size()-1;i>=0 && results[i]==results.back();--i);
	++i;
	results.erase(results.begin(), results.begin()+i);
	random_shuffle(results.begin(), results.end());
	cout << (results.back().column) << ' ' << results.back().orient << '\n';
}

int main () {
	string command, state;
	int i,j;
	int w = 8, h= 16;
	Field me, enemy;
	for (;;) {
		cin >> command;
		if (command=="Quit")
			return 0;
		else if (command=="Start"){
			cin >> xcur;
			cout << "SUrSU Exception Striker\n";
			cout.flush();
		}
		else if (command=="Move") {
			for (i=0;i<h;i++) {
				cin >> state;
				for (j=0;j<w;j++)
					me.state[i][j]=state[j];
			}
			for (i=0;i<h;i++) {
				cin >> state;
				for (j=0;j<w;j++)
					enemy.state[i][j]=state[j];
			}
			choose_hod(me,enemy);
			//cout << "0 0\n";
			cout.flush();
		}
	}

	return 0;
}
