def solve(N, S): for i in range(N - 2): if S[i:i + 3] in ('ooo', 'o-o', '-oo', 'oo-'): 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')