#include"bits/stdc++.h" using namespace std; #define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++) #define rep(i,n) REP((i),0,(n)) using ll = long long; using pii = pair; using pll = pair; using tp3 = tuple; using Mat = vector>; constexpr int INF = 1 << 28; constexpr ll INFL = 1ll << 60; constexpr int dh[4] = { 0,1,0,-1 }; constexpr int dw[4] = { -1,0,1,0 }; bool isin(const int H, const int W, const int h, const int w) { return 0 <= h && h < H && 0 <= w && w < W; } template T minch(T& l, T r) { return l = min(l, r); } template T maxch(T& l, T r) { return l = max(l, r); } template void output(const T& val) { cout << val << endl; } template void output(const vector& vec, const bool newline = false) { for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl; } template void output(const vector>& mat) { for (const auto& row : mat)output(row); } // ============ template finished ============ bool cont3(const string& s) { int cnt = 0; for (char c : s) { if (c == 'o')cnt++; else cnt = 0; if (cnt == 3)return true; } return false; } int reach(const string& s, const int near = -INF) { const int N = s.size(); int cnt = 0; set cand; if (near == -INF) { rep(i, N - 2) { map mp; REP(j, i, i + 3)mp[s[j]]++; if (mp['o'] == 2 && mp['-'] == 1) { REP(j, i, i + 3)if (s[j] == '-')cand.insert(j); } } } else { REP(i, max(0, near - 10), min(N - 2, near + 10)) { map mp; REP(j, i, i + 3)mp[s[j]]++; if (mp['o'] == 2 && mp['-'] == 1) { REP(j, i, i + 3)if (s[j] == '-')cand.insert(j); } } } return cand.size(); } bool solve(const int N, string& s) { if (cont3(s) || reach(s) >= 1)return true; rep(i, N) { char& c = s[i]; if (c == '-') { c = 'o'; if (reach(s, i) >= 2)return true; c = '-'; } } return false; } int main() { int T; cin >> T; while (T--) { int N; string s; cin >> N >> s; output(solve(N, s) ? "O" : "X"); } return 0; }