t = int(input()) for _ in range(t): info = list(input().split()) n, s = info n = int(n) li = s.split("x") for string in li: if len(string) <= 2: continue if string == "-o-": continue if string[1:-1].count("o") > 0: print("O") break if string[0] == "o" and string[-1] == "o" and len(string) % 2 == 1: print("O") break else: print("X")