import sys def input(): return sys.stdin.readline().strip() def mapint(): return list(map(int, input().split())) sys.setrecursionlimit(10**9) T = int(input()) def check(S): vic = 0 vic_prob = set() length = len(S) for i in range(length-2): s = ''.join(S[i:i+3]) if s=='ooo': vic += 1 elif s=='oo-' or s=='-oo' or s=='o-o': vic_prob.add(i+('-oo', 'o-o', 'oo-').index(s)) cnt = 0 o = True for i in range(length): if S[i]=='o': o = True if cnt % 2==1: vic += 1 cnt = 0 elif S[i]=='x': o = False cnt = 0 else: if o: cnt += 1 return vic, len(vic_prob) for _ in range(T): N, S = input().split() N = int(N) S = list(S) if N<3: print('X') continue v, p = check(S) if v>0 or p>0: print('O') continue flg = False for i in range(N): if S[i]=='-': S[i] = 'o' v, p = check(S) if p > 1: flg = True S[i] = '-' if flg: print('O') else: print('X')