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

public class Main
{
	public static void main(String[] args) throws IOException 
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		//PrintWriter outf = new PrintWriter(new FileWriter("oo.tt"));

		int h = 16;
		int w = 8;
		long x0 = 0;
		long x1 = 0;
		long a = (long)17235617;
		long b = (long)4311271;
		long mod = (long)87465851;
		for(int i = 0 ; ; ++i)
		{
			String str = in.next();
			if (str.equals("Quit"))
				break;
			else if (str.equals("Start"))
			{
				x0 = in.nextLong();
				x1 = (a * x0 + b) % mod;
				out.println("Lenyuk");
				out.flush();
			}
			else if (str.equals("Move"))
			{
				int[][] ourField = new int[h][w];
				int[][] opponentField = new int[h][w];
				int[] ourHigh = new int[w];
				int[] height = new int[w];
				for(int ii = 0; ii <  h; ii++){
					String s = in.next();
					for (int jj = 0; jj < w; jj++){
						char ss = s.charAt(jj);
						if (ss=='.'){
							ourField[15-ii][jj] = -1;
						} else {
							ourField[15-ii][jj] = ss - '0';
						}
						if (ss=='*'){
							ourField[15-ii][jj] = 0;
						}
					}
				}
				for(int ii = 0; ii <  h; ii++){
					String s = in.next();
					for (int jj = 0; jj < w; jj++){
						char ss = s.charAt(jj);
						if (ss=='.'){
							opponentField[15-ii][jj] = -1;
						} else {
							opponentField[15-ii][jj] = ss - '0';
						}
						if (ss=='*'){
							opponentField[15-ii][jj] = 0;
						}
					}
				}
				
				for (int ii = 0; ii<8; ii++ ){
					height[ii] = -1;
				}
				
				for (int ii=0; ii<16; ii++){
					for (int jj=0; jj<8; jj++){
						if (ourField[ii][jj]>=0){
							ourHigh[jj] = ourField[ii][jj];
							height[jj] = ii;
						}
					}
				}
				boolean find = false;
				int curA = 0, curB = 0;
				if (!find){
					for (int ii=0; ii<8; ii++){
						if (height[ii]<14){
							int jj = ii - 1;
							if (jj>=0){
								if (ourField[height[ii]+1][jj]==((x0 % 5) + 1) && ourField[height[ii]+2][jj]==((x1 % 5) + 1)){
									curA = ii;
									curB = 3;
									find = true;
									break;
								}
								if (ourField[height[ii]+1][jj]==((x1 % 5) + 1) && ourField[height[ii]+2][jj]==((x0 % 5) + 1)){
									curA = ii;
									curB = 1;
									find = true;
									break;
								}
							}
							jj += 2;
							if (jj<8){
								if (ourField[height[ii]+1][jj]==((x0 % 5) + 1) && ourField[height[ii]+2][jj]==((x1 % 5) + 1)){
									curA = ii;
									curB = 3;
									find = true;
									break;
								}
								if (ourField[height[ii]+1][jj]==((x1 % 5) + 1) && ourField[height[ii]+2][jj]==((x0 % 5) + 1)){
									curA = ii;
									curB = 1;
									find = true;
									break;
								}
							}
						}
					}
				}
				if (!find){
				for (int ii=0; ii<7; ii++){
					if (ourHigh[ii]==((x0 % 5) + 1) && ourField[15][ii]<0 && ourHigh[ii+1]==((x1 % 5) + 1) && ourField[15][ii+1]<0){
						curA = ii;
						curB = 0;
						find = true;
						break;
					}
				}
				}
				if (!find){
					for (int ii=1; ii<8; ii++){
						if (ourHigh[ii]==((x0 % 5) + 1) && ourField[15][ii]<0 && ourHigh[ii-1]==((x1 % 5) + 1) && ourField[15][ii-1]<0){
							curA = ii-1;
							curB = 2;
							find = true;
							break;
						}
					}
				}
				if (!find){
					for (int ii=0; ii<8; ii++){
						if (ourHigh[ii]==((x0 % 5) + 1) && ourField[15][ii]<0 && ((ii<7 && height[ii+1]<15) || (ii==7 && height[6]<15))){
							curA = ii;
							curB = 0;
							if (curA == 7) {
								curA = 6;
								curB = 2;
								if ((x0 % 5) == (x1 % 5)) {
									curA = 7;
									curB = 1;
								}
							}
							find = true;
							break;
						}
					}
				}
				if (!find){
					for (int ii=0; ii<8; ii++){
						if (ourHigh[ii]==((x1 % 5) + 1) && ourField[15][ii]<0 && ((ii>0 && height[ii-1]<15) || (ii==0 && height[1]<15))){
							curA = ii-1;
							curB = 0;
							if (ii == 0) {
								curA = 0;
								curB = 2;
							}
							find = true;
							break;
						}
					}
				}
				if (!find) {
					int minh = 50;
					for (int ii=0; ii<7; ii++){
						int hh = Math.max(height[ii], height[ii+1]);
						if (hh<minh){
							minh = hh;
							curA = ii;
							curB = 0;
						}
					}
										if (minh==15){
						for (int ii=0; ii<8; ii++){
							if (height[ii]<minh){
								curA = ii;
								curB = 1;
								minh = height[ii];
							}
						}
					}

				}
				if ((x0 % 5) == (x1 % 5) && height[curA]<13) {
					curB = 1;
				}
//				if (ourField[0][0]<=0){
//					out.println("0 1");
//				} else {
//					out.println("7 1");
//				}
//				out.print(i % w);
//				out.println(" 1");
//				outf.println(curA+" "+curB);
//				outf.flush();
				if (curA<0 || curA>7 || curB<0 || curB>3){
					out.println("1 1");
				} else {
					out.println(curA+" "+curB);
				}
				x0 = (a * x1 + b) % mod;
				x1 = (a * x0 + b) % mod;
				out.flush();
			}
		}

		out.close();
	}
}
