import sys
from collections import defaultdict

# Constants
MOD = int(1e9 + 7)

# Game state tracking
game_grid = []
state_map = defaultdict(int)
column_depth = [0] * 7  # Track the fill depth of each column

# Check for a 4-in-a-row pattern starting from a specific cell
def check_sequence(start_row, start_col, row_step, col_step, player):
    for i in range(4):
        row = start_row + i * row_step
        col = start_col + i * col_step
        if column_depth[col] > row or game_grid[row][col] != player:
            return False
    return True

# Count the number of "4-in-a-row" sequences for both players ('F' and 'C')
def count_sequences():
    rows = len(game_grid)
    cols = len(game_grid[0])
    player_f_count = 0
    player_c_count = 0

    for row in range(rows):
        for col in range(cols):
            if col + 3 < cols:  # Horizontal
                player_f_count += check_sequence(row, col, 0, 1, 'F')
                player_c_count += check_sequence(row, col, 0, 1, 'C')
            if row + 3 < rows:  # Vertical
                player_f_count += check_sequence(row, col, 1, 0, 'F')
                player_c_count += check_sequence(row, col, 1, 0, 'C')
            if row + 3 < rows and col + 3 < cols:  # Diagonal down-right
                player_f_count += check_sequence(row, col, 1, 1, 'F')
                player_c_count += check_sequence(row, col, 1, 1, 'C')
            if row + 3 < rows and col - 3 >= 0:  # Diagonal down-left
                player_f_count += check_sequence(row, col, 1, -1, 'F')
                player_c_count += check_sequence(row, col, 1, -1, 'C')

            # Stop counting early if both players have sequences
            if player_f_count > 0 and player_c_count > 0:
                return player_f_count, player_c_count
    return player_f_count, player_c_count

# Recursive function to simulate the game and determine the result
def simulate_game(turn):
    game_state = ''.join(map(str, column_depth))
    
    if game_state in state_map:
        return state_map[game_state]

    f_seq, c_seq = count_sequences()
    
    if f_seq == 0 and c_seq == 0:
        state_map[game_state] = 0
    elif f_seq > 0 and c_seq == 0:
        state_map[game_state] = 1
    elif f_seq == 0 and c_seq > 0:
        state_map[game_state] = -1
    else:
        current_player = 'F' if turn == 1 else 'C'
        result = 0

        for col in range(7):
            if column_depth[col] < len(game_grid) and game_grid[column_depth[col]][col] == current_player:
                column_depth[col] += 1
                opponent_result = simulate_game(1 - turn)
                column_depth[col] -= 1
                
                if opponent_result == 0:
                    continue
                elif opponent_result == 1:
                    result = max(result, 1)
                elif opponent_result == -1:
                    result = min(result, -1)

        state_map[game_state] = result
    return state_map[game_state]

# Handle input and process each test case
def process_case():
    global game_grid, column_depth, state_map
    state_map.clear()
    column_depth = [0] * 7  # Reset column depths
    game_grid = [input().strip() for _ in range(6)]  # Read the 6x7 grid
    return simulate_game(1)

# Main function to drive the program
if __name__ == "__main__":
    input = sys.stdin.read
    data = input().splitlines()

    test_cases = int(data[0])
    index = 1

    for case_num in range(1, test_cases + 1):
        game_grid = data[index:index + 6]
        index += 6

        print(f"Case #{case_num}: ", end="")
        result = process_case()

        if result == 1:
            print("F")
        elif result == -1:
            print("C")
        elif result == 0:
            print("0")
        else:
            print("?")
