#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

/*
 * ============================================================
 *  Domineering Sample Agent
 *  ------------------------------------------------------------
 *  - Board size: 8x8 (1-indexed)
 *  - This agent plays the lexicographically smallest legal move found on each turn.
 * ============================================================
 */

int weight[9][9]; // 1-based
int board[9][9];  // 1-based
int turn;

typedef struct { int x, y; } Move;

// ------------------------------------------------------------
// Find the first legal move available for the current player.
// Returns (x, y)
// ------------------------------------------------------------
Move find_move(int current_turn) {
    if (current_turn == 1) {
        for (int i = 1; i <= 8; i++) {
            for (int j = 1; j <= 7; j++) {
                if (board[i][j] != 0) continue;
                if (board[i][j + 1] != 0) continue;
                Move m = { i, j };
                return m;
            }
        }
    }
    else {
        for (int i = 1; i <= 7; i++) {
            for (int j = 1; j <= 8; j++) {
                if (board[i][j] != 0) continue;
                if (board[i + 1][j] != 0) continue;
                Move m = { i, j };
                return m;
            }
        }
    }
    Move none = { -1, -1 };
    return none;
}

// ------------------------------------------------------------
// Apply the player's move to the local board state.
// ------------------------------------------------------------
void apply_move(int x, int y, int current_turn) {
    if (x == -1 && y == -1) {
        return;
    }
    if (current_turn == 1) {
        assert(1 <= x && x <= 8);
        assert(1 <= y && y <= 7);
        assert(board[x][y] == 0);
        assert(board[x][y + 1] == 0);
        board[x][y] = current_turn;
        board[x][y + 1] = current_turn;
    }
    else {
        assert(1 <= x && x <= 7);
        assert(1 <= y && y <= 8);
        assert(board[x][y] == 0);
        assert(board[x + 1][y] == 0);
        board[x][y] = current_turn;
        board[x + 1][y] = current_turn;
    }
}

// ------------------------------------------------------------
// Main event loop: handles protocol commands and moves.
// ------------------------------------------------------------
int main(void) {
    // 1. 초기 가중치 입력 처리
    for (int i = 1; i <= 8; i++) {
        for (int j = 1; j <= 8; j++) {
            if (scanf("%d", &weight[i][j]) != 1) return 0;
        }
    }

    // 버퍼에 남은 개행문자(newline) 제거 (C++의 cin.ignore() 역할)
    int c;
    while ((c = getchar()) != '\n' && c != EOF);

    char line[256];
    // 2. 메인 이벤트 루프
    while (fgets(line, sizeof(line), stdin)) {
        size_t n = strlen(line);
        // 줄바꿈 문자 제거
        if (n && (line[n-1] == '\n' || line[n-1] == '\r')) {
            line[n-1] = '\0';
        }

        char cmd[16] = {0};
        if (sscanf(line, "%15s", cmd) != 1) continue;

        if (strcmp(cmd, "READY") == 0) {
            char role[16] = {0};
            if (sscanf(line, "%*s %15s", role) == 1) {
                turn = (strcmp(role, "FIRST") == 0) ? 1 : 2;
                printf("OK\n");
                fflush(stdout);
            }
        }
        else if (strcmp(cmd, "TURN") == 0) {
            int t1, t2;
            if (sscanf(line, "%*s %d %d", &t1, &t2) == 2) {
                Move m = find_move(turn);
                apply_move(m.x, m.y, turn);
                printf("MOVE %d %d\n", m.x, m.y);
                fflush(stdout);
            }
        }
        else if (strcmp(cmd, "OPP") == 0) {
            int x, y, t2;
            if (sscanf(line, "%*s %d %d %d", &x, &y, &t2) == 3) {
                apply_move(x, y, turn ^ 3);
            }
        }
        else if (strcmp(cmd, "FINISH") == 0) {
            break;
        }
    }
    
    return 0;
}