#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <ctime>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long int64;
typedef double real;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef pair<int,int> pip;

#if defined(I_LIKE_GENTOO)
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

const int W = 8;
const int H = 16;
int lastx_seed;
char buf[1<<10];
const int64 AA = 17235617;
const int64 BB = 4311271;
const int64 MOD = 87465851;
const int BLACK = 0;
const int EMPTY = -1;
char was[H][W];
pip q[H*W*2];
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int64 bonus[] = {0,0,3,6,12,24,50,100,100,100,100,100,100,100};
const int64 BALL_SCORE = 1000;
double ratio[] = {1-1,1-0.05,1-0.08,1-0.1,1-0.20};
int64 height_penalty[] = {0,0,0,0,0,0,10,20,30,40,50,70,90,110,150,180,400,inf};

inline int next_ball(int64 prev){
    return (prev*AA+BB)%MOD;
}

inline int get_ball(int x){
    return ((x%5)+1);
}

struct value_vector{
    int64 black_to_enemy;
    int64 height;
    int64 zone_3;
    int64 zone_2;
    int64 black_cnt;
    int64 kuchnost;
    int64 toint()const{
        return (black_to_enemy*BALL_SCORE) - height + 300*zone_3*zone_3 + 30*zone_2 - black_cnt*10000 - kuchnost*kuchnost*2500;
    }
};

struct field{
    char a[H][W];
    bool operator<(const field& f)const{
        return false;
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++) if (a[i][j] != f.a[i][j]) return a[i][j] < f.a[i][j];
        }
        return false;
    }
    void dump(){
        puts("dump");
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if (a[i][j] == EMPTY) printf(".");
                else if (a[i][j] == BLACK) printf("*");
                else printf("%d",int(a[i][j]));
            }
            puts("");
        }
    }

    int64 getheight(){
        int64 res = 0;
        for (int j = 0; j < W; j++) {
            int hh = H;
            for (int i = H-1; i >= 0; i--) if (a[i][j] == EMPTY){
                hh = H-1-i;
                break;
            }
//            res += (1<<hh);
            res += height_penalty[hh];
        }
 //       return res;
        return res*1000;
    }

    int64 getkuchnost(){
        memset(was,0,sizeof(was));
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++) if (a[i][j] > 0){
                was[a[i][j]][j] = 1;
            }
        }
        int group = 0;
        for (int i = 1; i <= 5; i++){
            int j = 0;
            for (;j<W;){
                for (;j<W && !was[i][j];j++);
                int st = j;
                if (st>=W)break;
                for (;j<W && was[i][j];j++);
                group++;
            }
        }
        return group;
    }

    value_vector damage(){
        int64 score = 0;
        int chain;
        int zone_3_cnt = 0;
        int zone_2_cnt = 0;
        int black_cnt = 0;
        for (chain=0;;chain++){
            bool did = false;
            memset(was,0,sizeof(was));
            int mega = 1;
            zone_3_cnt = 0;
            zone_2_cnt = 0;
            black_cnt = 0;
            for (int i = 0;  i < H; i++){
                for (int j = 0; j < W; j++) if (!was[i][j] && a[i][j] > 0){
                    mega++;
                    was[i][j] = mega;
                    int ba = 0;
                    int fr = 0;
                    q[fr++] = pip(i,j);
                    for (;ba<fr;){
                        int y = q[ba].first;
                        int x = q[ba].second;
                        ba++;
                        for (int d = 0; d < 4; d++){
                            int ay = y+dy[d];
                            int ax = x+dx[d];
                            if (ax < 0 || ay < 0 || ay >= H || ax >= W || a[ay][ax] != a[y][x] || was[ay][ax]) continue;
                            was[ay][ax] = mega;
                            q[fr++] = pip(ay,ax);
                        }
                    }
                    score += fr-1;
                    if (fr == 2) zone_2_cnt++;
                    else if (fr==3) zone_3_cnt++;
                    else if (fr >= 4){
                        did = true;
                        for (int k = 0; k < fr; k++){
                            int y = q[k].first;
                            int x = q[k].second;
                            a[y][x] = 0;
                            for (int d = 0; d < 4; d++){
                                int ay = y+dy[d];
                                int ax = x+dx[d];
                                if (ax < 0 || ay < 0 || ay >= H || ax >= W || a[ay][ax] != BLACK) continue;
                                a[ay][ax] = EMPTY;
                            }
                        }
                    }
                } else if (a[i][j] == BLACK){
                    black_cnt++;
                }
            }
            if (!did) break;
            fall();
        }
        int black_add = score-2+bonus[chain];
        if (chain==0) black_add = 0;
        value_vector res;
        res.black_to_enemy = black_add;
        res.height = getheight();
        res.zone_3 = zone_3_cnt;
        res.zone_2 = zone_2_cnt;
        res.black_cnt = black_cnt;
        res.kuchnost = getkuchnost();
        return res;
    }

    void fall(){
        for (int i = 0; i < W; i++){
            int j = H-1;
            int st = H-1;
            for (;j>=0;){
                for (;st>=0 && a[st][i] != EMPTY;st--);
                if (st<0)break;
                j=st-1;
                for (;j>=0&&a[j][i]==EMPTY;j--);
                if (j<0)break;
                swap(a[j][i],a[st][i]);
                st--;
            }
        }
    }

    bool add(int x, int v){
        for (int i = 0; i < H; i++){
            if (a[H-1-i][x] == EMPTY){
                a[H-1-i][x] = v;
                return true;
            }
        }
        return false;
    }
}f[2];

inline int parsechar(char x){
    if (x == '.') return EMPTY;
    if (x == '*') return BLACK;
    return x-'0';
}

typedef pair<int64,int> pzp;
typedef pair<pzp,pip> ppp;
typedef pair<int64,pip> pqp;
pqp get(const field& f, int lastx_seed, int togo){
    int x0 = lastx_seed;
    int x1 = next_ball(x0);
    int x2 = next_ball(x1);
    int b0 = get_ball(x0);
    int b1 = get_ball(x1);

    vector<pair<ppp,field> > all;

    for (int s = 0; s < W; s++){
        for (int r = 0; r < 4; r++){
            int p1 = s;
            int p2 = p1+dx[r];
            if (p2 < 0 || p2 >= W) continue;
            field tmp(f);
            if (p1==p2){
                if (r == 1){
                    if (!tmp.add(p2,b1)) continue;
                    if (!tmp.add(p1,b0)) continue;
                } else if (r==3){
                    if (!tmp.add(p1,b0)) continue;
                    if (!tmp.add(p2,b1)) continue;
                }
            } else {
                if (!tmp.add(p1,b0)) continue;
                if (!tmp.add(p2,b1)) continue;
            }
            value_vector zz = tmp.damage();
            int64 z = zz.toint();
            all.push_back(pair<ppp,field>(ppp(pzp(z,int(zz.black_to_enemy)),pip(s,r)),tmp));
        }
    }
    if (all.empty()) return pqp(-inf64,pip(-1,-1));
    sort(all.begin(),all.end());
    if (togo == 0){
        ppp& p = all[all.size()-1].first;
        return pqp(p.first.first,p.second);
    }
    int fr = int(all.size()*ratio[togo]);
    Eo(all.size());Eo(togo);Eo(ratio[togo]);Eo(fr);
    pqp res(-inf64,pip(-1,-1));
    for (int i = fr; i < all.size(); i++){
        pqp qq = get(all[i].second,x2,togo-1);
        if (qq.first <= -inf64) continue;
        qq.first = all[i].first.first.second*BALL_SCORE+qq.first;
        qq.second = all[i].first.second;
        if (qq>res) res = qq;
    }
    if (res.first <= -inf64){
        ppp& p = all[all.size()-1].first;
        return pqp(p.first.first,p.second);
    }
    return res;
}

int main(){
#if defined(I_LIKE_GENTOO)
    freopen("log","w",stderr);
#endif
    for (int turn = 0;;turn++){
        scanf("%s",buf);
        string s(buf);
        if (s == ("Quit")) return 0;
        if (s == "Start") {
            scanf("%d",&lastx_seed);
            puts("Package");
            fflush(stdout);
            continue;
        }else if (s == "Move"){
            for (int t = 0; t < 2; t++){
                for (int i = 0; i < H; i++){
                    scanf("%s",buf);
                    for (int j = 0; j < W; j++){
                        f[t].a[i][j] = parsechar(buf[j]);
                    }
                }
            }

            pqp sr = get(f[0],lastx_seed,4);
            lastx_seed = next_ball(next_ball(lastx_seed));
            int s = sr.second.first;
            int r = sr.second.second;
            s = min(s,s+dx[r]);
            if (s<0){
                s = r = 0;
            }
            Eo(sr.first);Eo(s);Eo(r);
            printf("%d %d\n",s,r);
            fflush(stdout);

        }else assert(0);
    }
    return 0;
}
