#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <queue>

using namespace std;                                                                                                               

#define forn(i,n) for (int i = 0; i < (int)n; i ++)
#define ford(i,n) for (int i = (int)n-1; i >= 0; i --)
#define fs first
#define sc second
#define x first
#define y second
#define pb push_back
#define all(a) a.begin(), a.end()
#define last(a) (int)a.size()-1 
#define I (int)
#define seta(x,y) memset (x, y, sizeof (x))
#define sqr(x) ((x)*(x))
#define mp make_pair

typedef long long int64;                                                                                          
typedef pair <int, int> pii;
typedef long double ldb;
typedef char field[19][8];

const int inf = (1 << 30) - 1;
const int64 inf64 = (1LL << 62) - 1;
const ldb eps = 1e-9;
const ldb pi = (ldb)4.*atan(1.);

const int w = 8;
const int h = 19;
                    
int x[300];

int64 x0;
char buf[100];	
field F, F1;
int64 x1, x2;

void gen (int64 x0) {
	for (int i = 0; i < 300; i ++) {
		x[i] = x0 % 5 + 1;
		x0 = (x0 * 17235617 + 4311271) % 87465851;
	}
}

const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int MyFree, HisFree, MyBlack, HisBlack;
pii moves1[30], moves2[30];
pii number[30];
const int PSIZE = 1;
bool u[h][w];
int K;

void dfs (field &F, int vx, int vy) {
	if (u[vx][vy])
		return;
	u[vx][vy] = 1;
	K ++;
	forn (i, 4) {
		int x = vx + dx[i];
		int y = vy + dy[i];
		if (x < 0 || x >= h || y < 0 || y >= w)
			continue;
		if (F[x][y] == F[vx][vy])
			dfs (F, x, y);
	}
}

void paint (field &F, int vx, int vy, char c1) {
	char c = F[vx][vy];
	F[vx][vy] = c1;
	forn (i, 4) {
		int x = vx + dx[i];
		int y = vy + dy[i];
		if (x < 0 || x >= h || y < 0 || y >= w)
			continue;
		if (F[x][y] == c)
			paint (F, x, y, c1);
	}
}

int process (field &F) {
	
	int minx[8];
	forn (i, 8)
		minx[i] = 18;
	for (int i = 18; i >= 0; i --)
		forn (j, 8)
			if (F[i][j] != '.') {
				char c = F[i][j];
				F[i][j] = '.';
				int p = minx[j];
				F[p][j] = c;
				minx[j] = p - 1;
			}
	forn (j, 8)
		if (F[2][j] != '.')
			return -inf;
	int res = 0;
	seta (u, 0);
	int c, k;
	c = 0;
	k = 0;
	forn (i, h)
		forn (j, 8)
			if (!u[i][j] && isdigit (F[i][j])) {
				K = 0;
				dfs (F, i, j);
				if (K >= 4) {
					k += K;
					c ++;
					paint (F, i, j, '-');
				}
			}
	if (c > 0)
		res = k - c - 2;
	forn (i, h)
		forn (j, 8)
			if (F[i][j] == '*')
				forn (k, 4)
					if (0 <= i + dx[k] && i + dx[k] < h && 0 <= j + dy[k] && j + dy[k] < w)
						if (F[i+dx[k]][j+dy[k]] == '-')
							F[i][j] = '.';							
	forn (i, h)
		forn (j, 8)
			if (F[i][j] == '-')
				F[i][j] = '.';
	return res;
}                                                                       

int make_move (field &F, int nummove, int DX) {
	pii p1 = moves1[nummove];
	pii p2 = moves2[nummove];
	F[p1.x][p1.y] = '0' + x[DX];
	F[p2.x][p2.y] = '0' + x[DX+1];
	int res = 0;
	int it = 0;
	while (1) {
		int x = process (F);
		res += x;
		if (x <= 0)
			break;
		else 
			it ++;
	}
	if (it >= 7)
		res += 100;
	else {
		int add[7] = {0, 0, 3, 6, 12, 24, 50};
		res += add[it];
	}         
	return res;
}

double calc (field &F, double* params) {
	seta (u, 0);
	int Free, Black;
	Free = Black = 0;
	forn (i, h)
		forn (j, 8)
			if (F[i][j] == '.')
				Free ++;
			else
			if (F[i][j] == '*')
				Black ++;
	double a1 = HisFree / (double)(MyFree + HisFree + 1.);
	double a2 = MyFree / (double)(MyFree + HisFree + 1.);
//	double res = a1 * (2./3. * (MyFree - Free) + (MyBlack - Black)) + 10. * a2 * (params[0]);
	return sqrt((double)Free) + sqrt (params[0]); 
}

double go (field &F, int maxdep, int nummove, int DX, double* params) {
	double param[PSIZE];
	memcpy (param, params, sizeof (param));
	param[0] += (make_move (F, nummove, DX));	
	if (param[0] < -10000)
		return -1e5 * maxdep;
	if (maxdep == 0)
		return calc (F, param);
	field Q;
	double res = -1e100;
	forn (i, 30) {
	        memcpy (Q, F, sizeof (F));
		double tmp = go (Q, maxdep-1, i, DX+2, param);
		if (tmp > res)
			res = tmp;
	}
	return res;
}

pii calc_next (field &F) {
	double best = -1e100;
	field Q;
	pii res = mp (0, 0);
	vector <int> P;
	P.resize (30);
	forn (i, 30)
		P[i] = i;
	random_shuffle (all (P));
	forn (i, 30) {
		memcpy (Q, F, sizeof (F));
		double X[PSIZE];
		X[0] = 0;
		double tmpres = go (Q, 2, P[i], 0, X);
		if (tmpres > best) {
			best = tmpres;
			res = number[P[i]];
		}                                             
	}
	return res;
}    

int main () {
	int it = 0;
	for (int i = 0; i < 8; i ++)
		for (int j = 0; j < 4; j ++) {
			pii P = mp (1+dx[j], i+dy[j]);
			if (P.sc < 0 || P.sc >= 8)
				continue;
			number[it] = mp (min (i, i+dy[j]), j);
			moves1[it] = mp (1, i);
			moves2[it] = P;
			it ++;
		}
	seta (F, '.');
	seta (F1, '.');
	while (1) {
		scanf ("%s", buf);
		if ((string)buf == "Start") {
			cin >> x0;
			printf ("MSU_ST\n");
		}  else
		if ((string)buf == "Quit")
			break;
		else
		if ((string)buf == "Move") {
			for (int i = 3; i < 19; i ++)
				for (int j = 0; j < 8; j ++)
					scanf (" %c", &F[i][j]);
			for (int i = 3; i < 19; i ++)
				for (int j = 0; j < 8; j ++)
					scanf (" %c", &F1[i][j]);     
			MyFree = HisFree = HisBlack = MyBlack = 0;
			forn (i, h)
				forn (j, 8)
					if (F[i][j] == '.')
						MyFree ++;
					else
					if (F[i][j] == '*')
						MyBlack ++;
			forn (i, h)
				forn (j, 8)
					if (F1[i][j] == '.')
						HisFree ++;
					else
					if (F1[i][j] == '*')
						HisBlack ++;
			gen (x0);
			x0 = (x0 * 17235617 + 4311271) % 87465851;
			x0 = (x0 * 17235617 + 4311271) % 87465851;
			pii tmp = calc_next (F);
			printf ("%d %d\n", tmp.fs, tmp.sc);
		}
		fflush (stdout);
	}
	return 0;
}
                                