#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("O");}else{puts("X");} #define MAX_N 200005 int main() { int T; cin >> T; rep(_,T){ int n; cin >> n; string s; cin >> s; s = "xxx" + s + "xxx"; int flag = 0; int mode = 0; int cnt = 0; rep(i,n){ if(s[i] == 'x'){ mode = 0; cnt = 0; }else if(s[i] == 'o'){ cnt++; if(s[i+1] != 'x' && cnt >= 3){ flag = 1; break; } if(s[i+1] != 'x' && s[i+2] != 'x' && cnt >= 2){ flag = 1; break; } if(mode != 0 && (cnt - mode) % 2 == 0){ flag = 1; break; } if(mode != 0 && cnt-mode==1 && (s[i+1]!='x'||mode>=2)){ flag = 1; break; } mode = cnt; }else{ cnt++; } } if(flag) yn; } return 0; }