#!/usr/bin/env python3 import sys input = sys.stdin.readline t = int(input()) for _ in range(t): n, s = input().split() s = "x" + s + "x" 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 if "--o-" in s: print("O") continue if "-o--" in s: print("O") continue l = 10**9 ok = False for i, ch in enumerate(s): if ch == "o": length = i - l if length > 3 and length % 2 == 0: ok = True l = i elif ch == "x": l = 10**9 if ok: print("O") else: print("X")