#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n) - 1; i >= 0; i--) #define range(a) a.begin(), a.end() int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); int T; cin >> T; while (T--) { int N; cin >> N; string S; cin >> S; S = "xxxxx" + S + "xxxxx"; N = S.size(); bool ans = false; ans |= S.find("ooo") != string::npos; ans |= S.find("o-o") != string::npos; ans |= S.find("oo-") != string::npos; ans |= S.find("-oo") != string::npos; int i = 0; while (i < N) { if (S[i] != 'o') { i++; continue; } int cnt = 0; i++; while (S[i] == '-') { i++; cnt++; } if (S[i] == 'x') { continue; } while (cnt > 1 && (cnt - 1) % 2 == 0) { cnt = (cnt - 1) / 2; } if (cnt == 1) { ans = true; } i++; } cout << (ans ? "O" : "X") << '\n'; } }