#include <bits/stdc++.h>
using namespace std;
int
main ()
{
// your code goes here
long long int i, j, k, t, count, count1;
char a[100][100];
bool flag;
cin >> t;
for (i = 0; i < t; i++){
count1 = 0;
long long int counto = 0;
long long int countx = 0;
for (j = 0; j < 3; j++){
for (k = 0; k < 3; k++){
cin >> a[j][k];
if (a[j][k] == '_'){
count1++;
}
else if (a[j][k] == 'X'){
countx++;
}
else if (a[j][k] == 'O'){
counto++;
}
}
}
if (((9-count1)/2)==counto){
flag = false;
count = 0;
long long int sum[190] = { 0 };
for (j = 0; j < 3; j++){
sum[0] = sum[0] + a[0][j];
sum[1] = sum[1] + a[1][j];
sum[2] = sum[2] + a[2][j];
sum[3] = sum[3] + a[j][0];
sum[4] = sum[4] + a[j][1];
sum[5] = sum[5] + a[j][2];
sum[6] = sum[6] + a[j][j];
sum[7] = sum[7] + a[j][2 - j];
}
for (j = 0; j < 8; j++){
if ((sum[j] % 88 == 0 || sum[j] % 79 == 0)){
if (count == 0){
count++;
}
else{
flag = true;
}
}
}
if (flag){
cout << "3" << endl;
}
else if ((count == 0 && count1 == 0) || count == 1){
cout << "1" << endl;
}
else if(count1!=0){
cout << "2" << endl;
}
}
else{
cout << "3" << endl;
}
}
return 0;
}
this is the question tictactoe please find the edge case i am missing @darshancool25
this is the submission link CodeChef: Practical coding for everyone