t = int(input()) for _ in range(t): n,s = input().split() n = int(n) cand = '' for c in s: if c=='x': cand = '' continue if len(cand) ==3 and cand in ('ooo','oo-','-oo','o-o'): print('O') break elif len(cand)==4 and cand in ('--o-', '-o--'): print('O') break else: cand = '' else: print('X')