题目链接:Chenchen, Tangtang and ZengZeng
/*
* [链接]:https://nanti.jisuanke.com/t/A1420
*
* [题意]:找到横着,竖着,斜着的相同的那一行相同的字符,不存在则输出”ongoing“
*
* [分析]:模拟即可
*
* [tricks]:
*
*
* [时间复杂度]:
*
*
*
*
*
* */
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void scan() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
string ss[5];
int main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
scan();
int t;
cin >> t;
while (t--) {
for (int i = 0; i < 3; i++) cin >> ss[i];
int flag = 1;
for (int i = 0; i < 3; i++) {
flag = 0;
for (int j = 0; j < 3; j++) {
if (ss[i][j] != ss[i][0] || ss[i][j] == '.') {
flag = 1;
break;
}
}
if (flag == 0) {
cout << ss[i][0] << endl;
break;
}
}
if (!flag) continue;
for (int j = 0; j < 3; j++) {
flag = 0;
for (int i = 0; i < 3; i++) {
if (ss[i][j] != ss[0][j] || ss[i][j] == '.') {
flag = 1;
break;
}
}
if (flag == 0) {
cout << ss[0][j] << endl;
break;
}
}
if (!flag) continue;
if (ss[0][0] == ss[1][1] && ss[1][1] == ss[2][2] && ss[0][0] != '.') {
cout << ss[0][0] << endl;
continue;
}
if (ss[0][2] == ss[1][1] && ss[2][0] == ss[1][1] && ss[1][1] != '.') {
cout << ss[1][1] << endl;
continue;
}
cout << "ongoing" << endl;
}
return 0;
}