import java.io.*;
import java.util.*;

public class Bot
{
	
	int[][] f;
	int[][] o;
	int[] empty;
	int[][] waves;
	int[][] wavessecond;
	int h = 16;
	int w = 8;
	Scanner in;
	int c1;
	int c2;
	int toq;
	int tor;
	int[][] profit;
	int[][] heightsums;
	
	
	public static void main(String[] args) throws Exception {
		new Bot().run();
	}
	public long nextColor(long c) {
		return (c*17235617 + 4311271) % 87465851;
	}
	public void run() throws Exception {
		in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		long x0 = 0;
		c1 = 0;
		c2 = 0;
		f = new int[h][w];
		o = new int[h][w];
		empty = new int[w];
		waves = new int[w][6];
		wavessecond = new int[w][6];
		profit = new int[w][4];
		heightsums = new int[w][2];
		int maxp;
		int maxq = 0;
		int maxr = 0;
		int maxh = 0;
		
		toq = 0;
		tor = 0;
		
		for(int i = 0 ; ; ++i)
		{
			String str = in.next();
			if (str.equals("Quit"))
				break;
			else if (str.equals("Start"))
			{
				x0 = in.nextLong();
				c1 = (int) ((x0 % 5) + 1);
				x0 = nextColor(x0);
				c2 = (int) ((x0 % 5) + 1);
				x0 = nextColor(x0);
				out.println("Duyet_i_muzyka_meshaet");
				out.flush();
			}
			else if (str.equals("Move"))
			{
				read();
				empty();
				waves();
				
				maxp = 0;
				for (int q=0;q<w-1;q++) {
					heightsums[q][0] = empty[q] + empty[q+1];
					profit[q][0] = waves[q][c1] + waves[q+1][c2] - badmove(q, q+1);
					if (profit[q][0] > maxp) {maxp = profit[q][0];maxq = q;maxr = 0;maxh = heightsums[q][0];}
					if (profit[q][0] == maxp) {
						if (heightsums[q][0] > maxh) {
							maxp = profit[q][0];maxq = q;maxr = 0;maxh = heightsums[q][0];
						}
					}
					
					profit[q][2] = waves[q][c2] + waves[q+1][c1] - badmove(q,q+1);
					if (profit[q][2] > maxp) {maxp = profit[q][2];maxq = q;maxr = 2;maxh=heightsums[q][0];}
					if (profit[q][2] == maxp) {
						if (heightsums[q][0] > maxh) {
							maxp = profit[q][2];maxq = q;maxr = 2;maxh = heightsums[q][0];
						}
					}
					
				}
				for (int q=0;q<w;q++) {
					heightsums[q][1] = empty[q] + empty[q]-1;
					profit[q][1] = waves[q][c2] + wavessecond[q][c1] - badmove(q,q);
					if (profit[q][1] > maxp) {maxp = profit[q][1];maxq = q;maxr = 1;maxh=heightsums[q][1];}
					if (profit[q][1] == maxp) {
						if (heightsums[q][1] > maxh) {
							maxp = profit[q][1];maxq = q;maxr = 1;maxh = heightsums[q][1];
						}
					}
					
					
					profit[q][3] = waves[q][c1] + wavessecond[q][c2] - badmove(q,q);
					if (profit[q][3] > maxp) {maxp = profit[q][3];maxq = q;maxr = 3;maxh=heightsums[q][1];}
					if (profit[q][3] == maxp) {
						if (heightsums[q][1] > maxh) {
							maxp = profit[q][3];maxq = q;maxr = 3;maxh = heightsums[q][1];
						}
					}
				}
				
				if (maxp == 2) {
					failsafe();
				} else {
					toq = maxq;
					tor = maxr;
				}
				
				/* ---------------------------------- STEP -------------------------*/
				out.println(toq + " " + tor);
				out.flush();

				/* ---------------------------------- COLORS -------------------------*/
				c1 = (int) ((x0 % 5) + 1);
				x0 = nextColor(x0);
				c2 = (int) ((x0 % 5) + 1);
				x0 = nextColor(x0);
			}
		}

		out.close();
	}
	
	public int wave(int y, int x, int c) {
		if (y < 0) return 0;
		if (f[y][x] > 0) return 0;
		int[] qy = new int[136];
		int[] qx = new int[136];
		boolean[][] been = new boolean[h][w];
		int l = 0;
		int r = 1;
		qy[0] = y;
		qx[0] = x;
		been[y][x] = true;
		int cnt = 0;
		int black = 0;
		while (r > l) {
			cnt++;
			y = qy[l];
			x = qx[l];
			if (y < h-1 && !been[y+1][x]) {
				if (f[y+1][x] == c) {
					qy[r] = y+1; qx[r] = x;
					been[qy[r]][qx[r]] = true; r++;
				} else if (f[y+1][x] == 8) {
					been[y+1][x] = true; black++;
				}
			}
			if (y > 0 && !been[y-1][x]) {
				if (f[y-1][x] == c) {
					qy[r] = y-1; qx[r] = x;
					been[qy[r]][qx[r]] = true; r++;
				} else if (f[y-1][x] == 8) {
					been[y-1][x] = true; black++;
				}
			}
			if (x > 0 && !been[y][x-1]) {
				if (f[y][x-1] == c) {
					qy[r] = y; qx[r] = x-1;
					been[qy[r]][qx[r]] = true; r++;
				} else if (f[y][x-1] == 8) {
					been[y][x-1] = true; black++;
				}
			}
			if (x < w-1 && !been[y][x+1]) {
				if (f[y][x+1] == c) {
					qy[r] = y; qx[r] = x+1;
					been[qy[r]][qx[r]] = true; r++;
				} else if (f[y][x+1] == 8) {
					been[y][x+1] = true; black++;
				}
			}
			l++;
		}
		if (cnt > 4) return cnt+(black/2);
		return cnt;
	}

	public void read() throws Exception {
		char chr;
		String s;
		for(int j = 0; j < h; j++) {
			s = in.next();
			for (int q=0;q<w;q++) {
				chr = s.charAt(q);
				f[j][q] = chr == '.' ? 0
						: (chr == '*' ? 8 
						: chr-'0');
			}
		}
		for(int j = 0; j < h; j++) {
			s = in.next();
			for (int q=0;q<w;q++) {
				chr = s.charAt(q);
				o[j][q] = chr == '.' ? 0
						: (chr == '*' ? 8 
						: chr-'0');
			}
		}
	}

	public void empty() throws Exception {
		for (int q=0;q<w;q++) {
			for (int j=h-1;j>=0;j--) {
				if (f[j][q] == 0) {
					empty[q] = j;
					break;
				}
			}
		}
	}

	public void waves() throws Exception {
		for (int q=0;q<w;q++) {
			waves[q][c1] = wave(empty[q], q, c1);
			waves[q][c2] = wave(empty[q], q, c2);
			if (empty[q] > 0) {
				wavessecond[q][c1] = wave(empty[q]-1, q, c1);
				wavessecond[q][c2] = wave(empty[q]-1, q, c2);
			}
		}				
	}
	
	public void failsafe() throws Exception {
		int minsum = -1;
		for (int q=0;q<w-1;q++) {
			if (heightsums[q][0] > minsum) {
				minsum = heightsums[q][0];toq = q;tor = 0;
			}
		}
		for (int q=0;q<w;q++) {
			if (heightsums[q][1] > minsum) {
				minsum = heightsums[q][1];toq = q;tor = 1;
			}
		}
	}

	public int badmove(int w1, int w2) throws Exception {
		if (empty[w1] < 1 || empty[w2] < 1) return 100500;
		if (empty[w1] < 4 || empty[w2] < 4) return 2;
		if (empty[w1] < 7 || empty[w2] < 7) return 1;
		return 0;
	}
}
