#!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop from itertools import permutations, accumulate import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()] def I(): return int(sys.stdin.buffer.readline()) def LS():return [list(x) for x in sys.stdin.readline().split()] def S(): res = list(sys.stdin.readline()) if res[-1] == "\n": return res[:-1] return res def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 def solve(): t = I() f = {"o":0, "x":1, "-":2} for _ in range(t): n,s = input().split() n = int(n) if n < 5: print("X") continue c = [0,0,0] c[f[s[0]]] += 1 c[f[s[1]]] += 1 for i in range(2,n): c[f[s[i]]] += 1 if c == [2,0,1] or c == [3,0,0]: print("O") break c[f[s[i-2]]] -= 1 else: c = [0,0,0] c[f[s[0]]] += 1 c[f[s[1]]] += 1 c[f[s[2]]] += 1 for i in range(3,n): c[f[s[i]]] += 1 if c == [1,0,3] and s[i] == "-" and s[i-3] == "-": print("O") break c[f[s[i-3]]] -= 1 else: c = [0,0,0] c[f[s[0]]] += 1 c[f[s[1]]] += 1 c[f[s[2]]] += 1 c[f[s[3]]] += 1 for i in range(4,n): c[f[s[i]]] += 1 if c == [2,0,3] and s[i] == "o" and s[i-4] == "o": print("O") break c[f[s[i-4]]] -= 1 else: print("X") return #Solve if __name__ == "__main__": solve()