import re import math 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-') != -1 \ or line.find('-o--') != -1 \ or re.search('o-+o_', line) \ or re.search('-o-+o', line): print('O') else: limit = int(math.log2(int(n)) + 1) for i in range(1, limit): desire = 'o' + '-'*(2**i-1) + 'o' if line.find(desire): print('O') continue print('X')