#!/usr/bin/env python3 import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n, s = input().split() n = int(n) if "ooo" in s: print("O") continue if "oo-" in s: print("O") continue if "-oo" in s: print("O") continue if "o-o" in s: print("O") continue if "o---o" in s: print("O") continue seed = s.count("-o-") side = s.count("xo-") + s.count("-ox") if seed > 0 and side > 0: print("O") continue print("X")