win = set([ "ooo", "oo-", "o-o", "-oo", ]) def game(N, S): for i in range(N - 2): if S[i] + S[i + 1] + S[i + 2] in win: 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")