t=int(input()) s=[input().split() for i in range(t)] for i in range(t): v=int(s[i][0]) if v<=2: print('X') elif v==3: if '-oo'==s[i][1] or 'o-o'==s[i][1] or 'oo-'==s[i][1] or 'ooo'==s[i][1]: print('O') else: print('X') else: flag=True for j in range(v-2): if '-oo'==s[i][1][j:j+3] or 'oo-'==s[i][1][j:j+3] or 'ooo'==s[i][1][j:j+3]: print('O') flag=False break if flag: for j in range(v-3): if '-o--'==s[i][1][j:j+4] or '--o-'==s[i][1][j:j+4]: print('O') flag=False break # 'o---o' を落とす flag1=True count=0 for j in range(v): if (s[i][1][j]=='o' and flag1) or (s[i][1][j]=='o' and not flag1 and count%2==0): flag1=False count=0 elif s[i][1][j]=='x': flag1=True count=0 elif s[i][1][j]=='-': count+=1 elif s[i][1][j]=='o' and not flag1 and count%2==1: print('O') flag=False break if flag: print('X')