def has_three_consecutive_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 def can_o_win(s): n = len(s) for i in range(n): if s[i] != '-': continue # Check left consecutive o's left = 0 j = i - 1 while j >= 0 and s[j] == 'o': left += 1 j -= 1 # Check right consecutive o's right = 0 j = i + 1 while j < n and s[j] == 'o': right += 1 j += 1 # Check conditions if left + right + 1 >= 3: return True if left >= 2 or right >= 2: return True return False T = int(input()) for _ in range(T): N, S = input().split() S = list(S) if has_three_consecutive_o(S): print("O") continue if can_o_win(S): print("O") else: print("X")