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