def determine_winner(n, s): # Check if current s has three consecutive 'o's if has_three_o(s): return "O" # Check if O can win in the next move for i in range(n): if s[i] == '-': # Check three possible patterns # Pattern 1: left two are 'o's if i >= 2 and s[i-2] == 'o' and s[i-1] == 'o': return "O" # Pattern 2: left and right are 'o's if i >= 1 and i < n-1 and s[i-1] == 'o' and s[i+1] == 'o': return "O" # Pattern 3: right two are 'o's if i <= n-3 and s[i+1] == 'o' and s[i+2] == 'o': return "O" # If none of the above, X wins return "X" 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() n = int(n) print(determine_winner(n, s))