#include <iostream>
using namespace std;
int main()
{
char tictactoe[3][3];
int circle_sum = 0,cross_sum = 0;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
cin >> tictactoe[i][j];
if (tictactoe[i][j] == '0') circle_sum++;
if (tictactoe[i][j] == 'X') cross_sum++;
}
}
string print;
if (cross_sum > circle_sum) print = "second";
if (cross_sum == circle_sum) print = "first";
if (cross_sum < circle_sum) print = "illegal";
if (cross_sum - circle_sum != 1 && cross_sum - circle_sum != 0) print = "illegal";
if (tictactoe[0][0] == 'X' && tictactoe[1][1] == 'X' && tictactoe[2][2] == 'X') print = "the first player won";
if (tictactoe[2][0] == 'X' && tictactoe[1][1] == 'X' && tictactoe[0][2] == 'X') print = "the first player won";
if (tictactoe[0][0] == 'X' && tictactoe[0][1] == 'X' && tictactoe[0][2] == 'X') print = "the first player won";
if (tictactoe[1][0] == 'X' && tictactoe[1][1] == 'X' && tictactoe[1][2] == 'X') print = "the first player won";
if (tictactoe[2][0] == 'X' && tictactoe[2][1] == 'X' && tictactoe[2][2] == 'X') print = "the first player won";
if (tictactoe[0][0] == 'X' && tictactoe[0][1] == 'X' && tictactoe[0][2] == 'X') print = "the first player won";
if (tictactoe[1][0] == 'X' && tictactoe[1][1] == 'X' && tictactoe[1][2] == 'X') print = "the first player won";
if (tictactoe[2][0] == 'X' && tictactoe[2][1] == 'X' && tictactoe[2][2] == 'X') print = "the first player won";
if (tictactoe[0][0] == '0' && tictactoe[1][1] == '0' && tictactoe[2][2] == '0') print = "the second player won";
if (tictactoe[2][0] == '0' && tictactoe[1][1] == '0' && tictactoe[0][2] == '0') print = "the second player won";
if (tictactoe[0][0] == '0' && tictactoe[0][1] == '0' && tictactoe[0][2] == '0') print = "the second player won";
if (tictactoe[1][0] == '0' && tictactoe[1][1] == '0' && tictactoe[1][2] == '0') print = "the second player won";
if (tictactoe[2][0] == '0' && tictactoe[2][1] == '0' && tictactoe[2][2] == '0') print = "the second player won";
if (tictactoe[0][0] == '0' && tictactoe[0][1] == '0' && tictactoe[0][2] == '0') print = "the second player won";
if (tictactoe[1][0] == '0' && tictactoe[1][1] == '0' && tictactoe[1][2] == '0') print = "the second player won";
if (tictactoe[2][0] == '0' && tictactoe[2][1] == '0' && tictactoe[2][2] == '0') print = "the second player won";
cout << print << endl;
return 0;
}
愿各位大佬神犇指教小的!