from itertools import groupby T = int(input()) def check(s, pattern): return s.count(pattern) > 0 for _ in range(T): _, s = input().split() ok = False ok |= check(s, 'ooo') ok |= check(s, 'oo-') ok |= check(s, '-oo') ok |= check(s, '-o--') ok |= check(s, '--o-') gb = groupby(list(s)) gbl = [(k, len(list(v))) for k, v in gb] for i in range(len(gbl) - 2): a,b,c = gbl[i : i + 3] if a[0] == 'o' and b[0] == '-' and c[0] == 'o' and b[1] % 2 == 1: ok = True break print("XO"[ok])