#include <iostream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <bitset>
#include <list>
#include <queue>
#include <deque>

using namespace std;

#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define for1(i, n) for(int i = 1; i <= int(n); ++i)
#define ford(i, n) for(int i = int(n)-1; i >= 0; --i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define all(v) (v).begin(), (v).end()
#define sz(v) int((v).size())

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = int(1E9);
const ld PI = acos(-1.0);
const ld EPS = 1E-9;

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

const int w = 8;
const int h = 16;

inline int nextX(int x){
    return (li(17235617)*li(x) + 4311271LL) % 87465851;
}

inline bool good(int x, int y){
    return 0 <= x && x < h && 0 <= y && y < w;
}

int c[h][w];
int cnt[130];
bool des[130];

struct field{
    char f[h][w];
    int hs[w];

    field(){ memset(f, '.', sizeof(f)); memset(hs, 0, sizeof(hs)); }
    //~field(){}

    field(const field& c){
        memcpy(f, c.f, sizeof(f));
        memcpy(hs, c.hs, sizeof(hs));
    }

    void copy(const field& c){
        memcpy(f, c.f, sizeof(f));
        memcpy(hs, c.hs, sizeof(hs));
    }

    (char*) operator [] (int i){
        return f[i];
    }

    void dfs(int x, int y){
        forn(i, 4){
            int nx = x + dx[i], ny = y + dy[i];
            
            if(good(nx, ny) && c[nx][ny] == -1 && f[x][y] == f[nx][ny]){
                c[nx][ny] = c[x][y];
                cnt[c[x][y]]++;
                dfs(nx, ny);
            }
        }
    }

    void boom(){
        memset(c, -1, sizeof(c));
        int cn = 0;

        forn(i, h)
            forn(j, w)
                if(c[i][j] == -1 && isdigit(f[i][j])){
                    cn++;
                    c[i][j] = cn - 1;
                    cnt[cn - 1] = 1;
                    dfs(i, j);
                }

        forn(i, cn)
            des[i] = (cnt[i] >= 4);

        bool death = false;

        forn(i, h)
            forn(j, w)
                if(c[i][j] != -1 && des[c[i][j]]){
                    death = true;
                    f[i][j] = '.';

                    forn(k, 4){
                        int nx = i + dx[k], ny = j + dy[k];

                        if(good(nx, ny) && f[nx][ny] == '*')
                            f[nx][ny] = '.';
                    }
                }

        forn(j, w){
            int bot = -1;
            ford(i, h){
                if(f[i][j] == '.' && bot == -1){
                    bot = i;
                }
                if(f[i][j] != '.' && bot != -1){
                    f[bot][j] = f[i][j];
                    f[i][j] = '.';
                    bot--;
                }
            }

            hs[j] = h - bot - 1;
        }

        if(death){
            boom();                            
        }
    }

    bool drop(int p, int c){
        if(hs[p] == h)
           return false;
        f[h - hs[p] - 1][p] = c + '0';
        hs[p]++;
        return true;
    }

    int getH(){
        return (*max_element(hs, hs + w));
    }
    pt getFunc(){
        int sum = 0;
        int mx = 0;
        forn(i, w){
            sum += hs[i];
            mx = max(mx, hs[i]);
        }
        return pt(sum, -mx);
    }

};

field f;

const int DEPTH = 3;
const int NMAX = 1000000;
const string name = "SarBot4";

int xs[NMAX];

inline bool goodMove(int i, int j){
    int p = i + dx[j];

    return 0 <= i && i < w && 0 <= j && j < 4 && 0 <= p && p < w;
}

inline pt makeMove(int i, int j){
    int p = i + dx[j];

    return pt(min(i, p), j);
}

pt solve(int idx, int p, int d, int mi){
    if(idx == DEPTH){
        return f.getFunc(); 
    }

    field cf(f);

    int p1 = p, p2 = p + dx[d];
    if(p2 < 0 || p2 >= w)
        return pt(100500, 100500);
    int c1 = xs[2*mi - 2];
    int c2 = xs[2*mi - 1];


    if(p1 == p2){
        if(dy[d] == -1){
            if(!f.drop(p1, c1))
                return pt(100500, 100500);
            if(!f.drop(p2, c2))
                return pt(100500, 100500);
        }else{
            if(!f.drop(p2, c2))
                return pt(100500, 100500);
            if(!f.drop(p1, c1))
                return pt(100500, 100500);
        }
    }else{
        if(!f.drop(p1, c1))
            return pt(100500, 100500);
        if(!f.drop(p2, c2))
            return pt(100500, 100500);
    }
    
    f.boom();

    pt ans(0, 1);
    pt r(100500, 100500);

    forn(i, w)
        forn(j, 4){
            int p2 = i + dx[j];
            if(p2 < 0 || p2 >= w)
                continue;
            pt cur = solve(idx + 1, i, j, mi + 1);
            if(goodMove(i, j) && r > cur){
                ans = makeMove(i, j);
                r = cur;
            }                                             
        }

    f.copy(cf);

    return r;
}

char trash[20];
                     
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int x;


    for(int mi = 0; ; ++mi){
        string s;
        cin >> s;

        if(strcmp(s.c_str(),"Quit") == 0){
            break;
        }   

        if(strcmp(s.c_str(),"Start") == 0){
            cin >> x;

            xs[0] = x;
            for(int i = 1; i < NMAX; ++i){
                xs[i] = nextX(xs[i - 1]);
            }
            for(int i = 0; i < NMAX; ++i)
                xs[i] = xs[i] % 5 + 1;

            cout << name << "\n";
            cout.flush();

            continue;
        }
        
        if(strcmp(s.c_str(), "Move") == 0){
            memset(f.hs, 0, sizeof(f.hs));

            forn(i, h){
                forn(j, w){
                    scanf(" %c", &f[i][j]);
                    if(f[i][j] != '.'){
                        f.hs[j] = max(f.hs[j], h - i);
                    }
                }
            }

            forn(i, h)
                scanf(" %s", trash);

            pt ans(0, 1);
            pt r(100500, 100500);

            forn(i, w)
                forn(j, 4){
                    int p2 = i + dx[j];
                    if(p2 < 0 || p2 >= w)
                        continue;
                    pt cur = solve(0, i, j, mi);
                    if(goodMove(i, j) && r > cur){
                        ans = makeMove(i, j);
                        r = cur;
                    }                                             
                }

            cout << ans.X << " " << ans.Y << "\n";
            cout.flush();
        }
    }

    return 0;    
}
    