import sys

cand = ['--o-', '-o--', '-oo', 'oo-', 'ooo', 'o-o', 'o---o', 'o-------o', '--------o---------']

t = int(sys.stdin.readline().rstrip())

def main():
    for _ in range(t):
        n, s = sys.stdin.readline().split()
        for c in cand:
            if s.find(c) != -1:
                print('O')
                break
        else:
            print('X')
        
if __name__ == '__main__':
    main()