#include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int tt; cin >> tt; while (tt--) { int n; cin >> n; string s; cin >> s; auto cnt = [&] { int res = 0; for (int i = 0; i < n; ++i) { if (s[i] == '-') { res += (i and s[i - 2] == 'o' and s[i - 1] == 'o') or (i and i + 1 < n and s[i - 1] == 'o' and s[i + 1] == 'o') or (i + 2 < n and s[i + 1] == 'o' and s[i + 2] == 'o'); } } return res; }; [&] { for (int i = 0; i + 3 <= n; ++i) { int o = count(begin(s) + i, begin(s) + (i + 3), 'o'); int x = count(begin(s) + i, begin(s) + (i + 3), 'x'); int _ = 3 - o - x; if (o == 3 or (o == 2 and _ == 1)) { cout << "O\n"; return; } } for (int i = 0; i < n; ++i) { if (s[i] == '-') { s[i] = 'o'; if (cnt() >= 2) { cout << "O\n"; return; } s[i] = '-'; } } for (int w = 2; w < n; w *= 2) { for (int i = 0; i + w < n; ++i) { if (s[i] == 'o' and s[i + w] == 'o') { if (count(begin(s) + (i + 1), begin(s) + (i + w), '-') == w - 1) { cout << "O\n"; } } } } cout << "X\n"; }(); } }