#include #define endl codeforces #define ALL(v) std::begin(v), std::end(v) #define ALLR(v) std::rbegin(v), std::rend(v) using ll = std::int64_t; using ull = std::uint64_t; using pii = std::pair; using tii = std::tuple; using pll = std::pair; using tll = std::tuple; template using vec = std::vector; template using vvec = vec>; template const T& var_min(const T &t) { return t; } template const T& var_max(const T &t) { return t; } template const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); } template const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); } template void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } template const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); } template void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); } template T make_v(T init) { return init; } template auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec(s, v); } template struct multi_dem_array { using type = std::array::type, Head>; }; template struct multi_dem_array { using type = std::array; }; template using mdarray = typename multi_dem_array::type; namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; } bool solve() { ll n; std::string s; std::cin >> n >> s; auto valid = [&](ll i) { return 0 <= i && i < n; }; auto check = [&](ll l, ll r, const std::string &ss) { if (!valid(l)) return false; if (!valid(r - 1)) return false; return s.substr(l, r - l) == ss; }; for (ll i = 0; i + 3 < s.size(); i++) if (check(i, i + 3, "ooo")) return true; for (ll i = 0; i < s.size(); i++) { if (s[i] != '-') continue; s[i] = 'o'; for (ll j = -4; j <= 4; j++) if (check(i + j, i + j + 4, "-oo-")) return true; for (ll j = -3; j <= 3; j++) if (check(i + j, i + j + 3, "ooo")) return true; s[i] = '-'; } for (ll i = 0; i < s.size(); i++) { if (s[i] != 'o') continue; ll l = i; ll r = i + 1; bool ok = true; while (r < s.size()) { if (s[r] == 'o') break; if (s[r] == 'x') { ok = false; break; } r++; } if (ok && (r - l) % 2 == 0) return true; } return false; } int main() { ll t; std::cin >> t; while (t--) std::cout << (solve() ? 'O' : 'X') << '\n'; return 0; }