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

import javax.print.attribute.standard.DateTimeAtCompleted;

import com.sun.corba.se.impl.interceptors.PINoOpHandlerImpl;
import com.sun.net.ssl.internal.ssl.Debug;

public class SampleBot
{
	
	static class Glass {
		int totalCnt = 0;
		int blackCnt = 0;
		int threeGroupCnt = 0;
		int twoGroupCnt = 0;
		int maxHeight = 0;
		
		final int h = 16;
		int w = 8;
		char balls[][];
		
		public Glass(){
			balls = new char[16][8]; 
		}
		
		public void read(Scanner in){
			for(int j = 0; j < h; j++) {
				String s = in.next();
				for (int i=0;i<w;i++)
					balls[j][i] = s.charAt(i);
			}
		}
		
		public Glass put(int s,int r,char b1,char b2) {
			if (r == 1) {
				char k = b2;
				b2 = b1;
				b1 = k;
				r = 3;
			}
			if (r == 2){
				char k = b2;
				b2 = b1;
				b1 = k;
				r = 0;
			}
			if (balls[0][s] != '.')
				return null;
			if (r == 3 && balls[1][s] != '.')
				return null;
			if (r == 0 && s==7)
				return null;
			if (r == 0 && balls[0][s+1] != '.')
				return null;
			Glass result = new Glass();
			for (int i=0;i<w;i++)
				for (int j=0;j<h;j++)
					result.balls[j][i] = balls[j][i];
			
			if (r == 0) {
				result.balls[0][s] = b1;
				result.balls[0][s+1] = b2;
			} else {
				result.balls[0+1][s] = b1;
				result.balls[0][s] = b2;
			}
			
			result.fall();
			result.explodeAll();
			return result;
		}
		
		void fall() {
			for (int c = 0; c < w; c++) {
				int pos = h - 1;
				while (pos >= 0 && balls[pos][c] != '.') {
					pos--;
				}
				for (int r = pos - 1; r >= 0; r--) {
					if (balls[r][c] != '.') {
						balls[pos][c] = balls[r][c];
						balls[r][c] = '.';
						pos--;
					}
				}
			}
		}
		
		int explodeAll(){
			int descroyedCnt = 0;
			int itCnt = 0;
			while (true) {
				fall();
				int curCnt = findAndDestroy();
				if (curCnt == 0) {
					break;
				}
				descroyedCnt += curCnt;
				itCnt++;
			}
			return descroyedCnt;
		}
		
		int findAndDestroy() {
			totalCnt = 0;
			blackCnt = 0;
			threeGroupCnt = 0;
			twoGroupCnt = 0;
			maxHeight = 0;
			
			int dCnt = 0;
			boolean[][] was = new boolean[h][w];
			for (int r = 0; r < h; r++) {
				for (int c = 0; c < w; c++) {
					if (balls[r][c] != '.') {
						totalCnt++;
						maxHeight = Math.max(maxHeight, h - r);
						if (balls[r][c] == '*') {
							blackCnt++;
						}
					}
					
					if (balls[r][c] != '.' && balls[r][c] != '*' && !was[r][c]) {
						int count = getCount(r, c, balls[r][c], was);
						
						if (count == 3) {
							threeGroupCnt++;
						} else 
							if (count == 2) {
								twoGroupCnt++;
							}
						
						if (count >= 4) {
							destroy(r, c, balls[r][c]);
							dCnt += count;
						}
					}
				}
			}
			return dCnt;
		}
		
		void destroy(int r, int c, char color) {
			if (!validate(r, c)) {
				return;
			}
			if (balls[r][c] == '*') {
				balls[r][c] = '.';
				return;
			}
			if (balls[r][c] != color) {
				return;
			}
			balls[r][c] = '.';
			for (int[] d : dirs) {
				int rn = r + d[0];
				int cn = c + d[1];
				destroy(rn, cn, color);
			}			
		}
		
		int[][] dirs = {
				{0, -1},
				{0, 1},
				{-1, 0},
				{1, 0}
		};
		
		boolean validate(int r, int c) {
			return (r >= 0 && r < h && c >= 0 && c < w);
		}
		
		int getCount(int r, int c, char color, boolean[][] was) {
			if (!validate(r, c)) {
				return 0;
			}
			
			if (was[r][c]) {
				return 0;
			}

			if (balls[r][c] != color) {
				return 0;
			}
			
			was[r][c] = true;
			
			int res = 1;
			for (int[] d : dirs) {
				int rn = r + d[0];
				int cn = c + d[1];
				res += getCount(rn, cn, color, was);
			}
			
			return res;			
		}
		
		double getEstimate() {
			return 
			-6 * totalCnt 
			-2 * maxHeight
			+3 * threeGroupCnt 
			+2 * twoGroupCnt 
			-15 * blackCnt
			;
		}		
		
		void dump() {
			for (char[] arr : balls) {
				log.println(arr);
			}
			log.printf("totalCnt=%d, maxHeight=%d, threeGroupCnt=%d, twoGroupCnt=%d, blackCnt=%d\n", totalCnt,maxHeight,threeGroupCnt,twoGroupCnt,blackCnt);
		}
	}
	
	static int figures[] = new int[100000];
	
	static class Move {
		int r;
		int s;
		double w;
		
		Move(int s,int r,double w){
			this.s = s;
			this.r = r;
			this.w = w;
		}
		
	}
	
	public static void main(String[] args) throws IOException 
	{
		try {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		if (debug)
			log = new PrintWriter(new FileWriter(Calendar.getInstance().getTimeInMillis() + ".txt"));

		for(int i = 0 ; ; ++i)
		{
			String str = in.next();
			if (str.equals("Quit"))
				break;
			else if (str.equals("Start"))
			{
				figures[0] = in.nextInt();
				for (int j=0;j<99999;j++)
					figures[j+1] = (int)((figures[j] * 17235617L + 4311271L) % 87465851L);
				out.println("Boris from Moscow");
				out.flush();
			}
			else if (str.equals("Move"))
			{
				if (debug)
					log.println("********* step "+i+" ***********");
				Move ans = null;
				Glass current = new Glass();
				current.read(in);
				for(int j = 0; j < 16; j++)
					in.next();
				if (debug)
					current.dump();
				char b1 = (char)(figures[i*2-2] % 5 + 1 +'0'),b2 = (char)(figures[i*2-1] % 5 + 1+'0');
				for (int s = 0;s<7;s++)
					for (int r=0;r<4;r++) {
						Glass m = current.put(s, r, b1, b2);
						if (m != null) {
							if (ans == null)
								ans = new Move(s,r,m.getEstimate());
							else if (ans.w < m.getEstimate())
								ans = new Move(s,r,m.getEstimate());
						}
					}
				if (debug) {
					log.println("ans "+i);
					if (ans != null) {
						Glass ans1 = current.put(ans.s, ans.r, b1, b2);
						ans1.dump();
					}
				}
				if (ans != null)
					out.println(ans.s+" "+ans.r);
				else 
					out.println(0+" "+0);
				out.flush();
			}
		}

		out.close();
		if (debug)
			log.close();
		} catch (Exception e) {
			if (debug) {
				e.printStackTrace(log);
				log.close();
			}
			throw new RuntimeException(e);
		}
	}
	
	static boolean debug = false;
	static PrintWriter log; 
}
