#include using namespace std; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a split(string& s,char c){ int n=s.size(); vector res; for(int i=0;i>n; string s; cin>>s; vector wins({"ooo","oo-","o-o","-oo","-o--","--o-"}); for(string w:wins){ if(s.find(w)!=string::npos){ cout<<"O\n"; return 0; } } auto ss=split(s,'x'); for(string t:ss){ if(t.size()<3) continue; if(t.front()!='o'||t.back()!='o') continue; if(t.size()&1){ cout<<"O\n"; return 0; } } cout<<"X\n"; return 0; } //INSERT ABOVE HERE signed main(){ cin.tie(0); ios::sync_with_stdio(0); int T; cin>>T; while(T--) solve(); return 0; }