#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <iomanip>
using namespace std;
int main()
{
	char chess[100][100];
	int x,y,i;
	ifstream f("DATA2.TXT");
	ofstream g("OUT2.TXT");
	for (i=1;i<=5;i++)
	{
		for (y=1;y<=3;y++)
			for (x=1;x<=3;x++)
				f>>chess[y][x];
			if (chess[1][1]=='X'&&chess[1][2]=='X'&&chess[1][3]=='X'){ //horizontal
			g<<'X'<<endl;
			continue;
		}
		if (chess[1][1]=='O'&&chess[1][2]=='O'&&chess[1][3]=='O'){
			g<<'O'<<endl;
			continue;
		}
		if (chess[2][1]=='X'&&chess[2][2]=='X'&&chess[2][3]=='X'){
			g<<'X'<<endl;
			continue;
		}
		if (chess[2][1]=='O'&&chess[2][2]=='O'&&chess[2][3]=='O'){
			g<<'O'<<endl;
			continue;
		}
		if (chess[3][1]=='X'&&chess[3][2]=='X'&&chess[3][3]=='X'){
			g<<'X'<<endl;
			continue;
		}
		if (chess[3][1]=='O'&&chess[3][2]=='O'&&chess[3][3]=='O'){
			g<<'O'<<endl;
			continue;
		}
		if (chess[1][1]=='X'&&chess[2][2]=='X'&&chess[3][3]=='X'){ //diagonal
			g<<'X'<<endl;
			continue;
		}
		if (chess[1][1]=='O'&&chess[2][2]=='O'&&chess[3][3]=='O'){
			g<<'O'<<endl;
			continue;
		}
		if (chess[3][1]=='O'&&chess[2][2]=='O'&&chess[1][3]=='O'){
			g<<'O'<<endl;
			continue;
		}
		if (chess[3][1]=='X'&&chess[2][2]=='X'&&chess[1][3]=='X'){
			g<<'X'<<endl;
			continue;
		}
		if (chess[1][1]=='X'&&chess[2][1]=='X'&&chess[3][1]=='X'){ //down 
			g<<'X'<<endl;
			continue;
		}
		if (chess[1][1]=='O'&&chess[2][1]=='O'&&chess[3][1]=='O'){
			g<<'O'<<endl;
			continue;
		}
		if (chess[1][2]=='X'&&chess[2][2]=='X'&&chess[3][2]=='X'){
			g<<'X'<<endl;
			continue;
		}
		if (chess[1][2]=='O'&&chess[2][2]=='O'&&chess[3][2]=='O'){
			g<<'O'<<endl;
			continue;
		}
		if (chess[1][3]=='X'&&chess[2][3]=='X'&&chess[3][23]=='X'){
			g<<'X'<<endl;
			continue;
		}
		if (chess[1][3]=='O'&&chess[2][3]=='O'&&chess[3][23]=='O')  
		{
			g<<'O'<<endl;
			continue;
		}
		g<<'.'<<endl;
	}
	return 0;
}
