t = int(input()) tr = ["o" + "-" * (2 ** i - 1) + "o" for i in range(2, 11)] for _ in range(t): _, S = input().split() if any(i in S for i in ["oo-","-oo","ooo","o-o","--o-","-o--"] + tr): print("O") else: print("X")