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, 'o-o') ok |= check(s, 'oo-') ok |= check(s, '-oo') ok |= check(s, '-o--') ok |= check(s, '--o-') print("XO"[ok])