def has_three_o(s): for i in range(len(s) - 2): if s[i] == 'o' and s[i+1] == 'o' and s[i+2] == 'o': return True return False T = int(input()) for _ in range(T): N, S = input().split() S = S.strip() if has_three_o(S): print("O") continue c = S.count('-') m = (c + 1) // 2 # O's remaining moves possible = False for i in range(len(S) - 2): a = 0 b = 0 for j in range(3): if S[i + j] == 'o': a += 1 elif S[i + j] == '-': b += 1 needed = max(0, 3 - a) ceil_b = (b + 1) // 2 # ceil(b/2) if min(m, ceil_b) >= needed: possible = True break print("O" if possible else "X")