def solve(N, S): for i in range(N - 2): if S[i:i + 3] in ('ooo', 'o-o', '-oo', 'oo-'): return True for i in range(N - 3): if S[i:i + 4] in ('-o--', '--o-'): return True return False T = int(input()) for _ in range(T): N, S = input().split() N = int(N) print('O' if solve(N, S) else 'X')