win3 = set([ "ooo", "oo-", "o-o", "-oo", ]) win4 = set([ "--o-", "-o--", ]) def game(N, S): for i in range(N - 2): if S[i] + S[i + 1] + S[i + 2] in win3: return True for i in range(N - 3): if S[i] + S[i + 1] + S[i + 2] + S[i + 3] in win4: return True return False if __name__ == "__main__": T = int(input()) ans = [] for _ in range(T): _, S = input().split() N = len(S) if game(N, S): ans.append("O") else: ans.append("X") print(*ans, sep="\n")