from itertools import groupby
import sys
input = sys.stdin.readline

T = int(input())
for _ in range(T):
    __, s = input().split()
    a = [('x', 0)] + [(k, len(list(v))) for k, v in groupby(s)] + [('x', 0)]

    for (k1, c1), (k2, c2), (k3, c3) in zip(a, a[1:], a[2:]):
        if (
            k2 == 'o' and (
                c2 >= 3
                or c2 == 2 and (k1 == '-' or k3 == '-')
                or c2 == 1 and k1 == k3 == '-' and c1+c3 >= 3
            )
            or k1 == k3 == 'o' and k2 == '-' and c2 % 2 == 1
        ):
            print('O')
            break
    else:
        print('X')