def main():
    import sys
    input = sys.stdin.readline

    for _ in range(int(input())):
        N, line = input().split()
        N = int(N)
        ans = 'X'
        for i in range(N-2):
            s = line[i: i+3]
            if s == 'ooo' or s == 'oo-' or s == 'o-o' or s == '-oo':
                ans = 'O'
        for i in range(N-3):
            s = line[i: i + 4]
            if s == '-o--' or s == '--o-':
                ans = 'O'
        for i in range(N-4):
            s = line[i: i+5]
            if s == 'o---o':
                ans = 'O'
        flg = 0
        cnt = 0
        for i, s in enumerate(line):
            if flg == 0:
                if s == '-' and i:
                    if line[i-1] == 'o':
                        flg = 1
                        cnt += 1
            elif flg == 1:
                if s == '-':
                    cnt += 1
                elif s == 'o':
                    if cnt & 1:
                        ans = 'O'
                        break
                    else:
                        flg = 0
                        cnt = 0
                elif s == 'x':
                    flg = 0
                    cnt = 0
        print(ans)


if __name__ == '__main__':
    main()