t = int(input()) for _ in range(t): n, line = input().split() if line.find('ooo') != -1 \ or line.find('-oo') != -1 \ or line.find('oo-') != -1 \ or line.find('o-o') != -1 \ or line.find('o---o') != -1 \ or line.find('--o-') != -1 \ or line.find('-o--') != -1 \ or line.find('o-------o') != -1: print('O') else: for i in range(4, int(n)//3): desire = 'o' + '-'*(2**i-1) + 'o' if line.find(desire) != -1: print('O') continue print('X')