#!/usr/bin/env python3

# To change this license header, choose License Headers in Project Properties.
# To change this template file, choose Tools | Templates
# and open the template in the editor.

import sys

def ResVelha(v):
    resolvido = False;
    contX = 0
    contO = 0
# linhas
    for x in range(0,3):
        contX = 0;
        contO = 0;
        for y in range(0,3):
            if v[x][y] == 1:
                contX += 1;
            elif v[x][y] == -1:
                contO += 1
                
        if contX == 3 or contO == 3:
            resolvido = True
            break
               
    if resolvido:
        if contX == 3:
            return 1
        else:
            return -1
            
    resolvido = False;
#colunas
    for x in range(0,3):
        contX = 0
        contO = 0
        for y in range(0,3):
            if v[y][x] == 1:
                contX += 1
            elif v[y][x] == -1:
                contO += 1
        
        if contX == 3 or contO == 3:
            resolvido = True;
            break
            
    if resolvido:
        if contX == 3:
            return 1
        else:
            return -1

    resolvido = False;
    contX = 0
    contO = 0
    
#diagonal principal
    for x in range(0,3):
        if v[x][x] == 1:
            contX += 1
        elif v[x][x] == -1:
            contO += 1
            
        if contX == 3 or contO == 3:
            resolvido = True;
            break

    if resolvido:
        if contX == 3:
            return 1
        else: 
            return -1;

    resolvido = False
    contX = 0
    contO = 0

# diagonal secundaria

    for x in range(0,3):
        if v[x][2 - x] == 1:
            contX += 1
        elif v[x][2 - x] == -1:
            contO += 1
        
        if contX == 3 or contO == 3:
            resolvido = True
            break
    if resolvido:
        if contX == 3:
            return 1
        else:
            return -1

    contX = 0
    contO = 0

# empate
    for x in range(0,3):
        for y in range(0,3):
            if v[x][y] == 1:
                contX += 1
            elif v[x][y] == -1:
                contO += 1
    if contX + contO == 9:
        return 0

    return -2

if __name__ == "__main__":

    while True:
        linha = raw_input()
    
        if linha in '0':
            break
    
        l = 0;

        v = []
            
        for i in range(0,3):
            v.append( [i] * 3 )

        temp = linha.split(" ")

        for c in range(0,3):
            v[l][c] = int(temp[c])
            
        l += 1

        for x in range(1,3):
            linha = raw_input()
            temp = linha.split(" ")
            for c in range(0,3):
                v[l][c] = int(temp[c])
            l += 1
            
        r = ResVelha(v)
            
        if r==1:
            print("X");
        elif r==-1:
            print("O");
        else:
            print("Empate");
    
    sys.exit()
