def main(): import sys input = sys.stdin.read().split() T = int(input[0]) idx = 1 for _ in range(T): N = int(input[idx]) S = input[idx+1] idx += 2 # Check if there are already three consecutive 'o's has_three = False for i in range(len(S)-2): if S[i] == 'o' and S[i+1] == 'o' and S[i+2] == 'o': has_three = True break if has_three: print('O') continue # Check if O can win in the next move can_win = False for i in range(len(S)): if S[i] != '-': continue # Check left two if i >= 2 and S[i-1] == 'o' and S[i-2] == 'o': can_win = True break # Check left and right if i >= 1 and i < len(S)-1 and S[i-1] == 'o' and S[i+1] == 'o': can_win = True break # Check right two if i < len(S)-2 and S[i+1] == 'o' and S[i+2] == 'o': can_win = True break if can_win: print('O') else: print('X') if __name__ == '__main__': main()