import sys input = sys.stdin.readline T=int(input()) Q=[list(input().split()[1]) for i in range(T)] import copy for S in Q: N=len(S) flag=0 S2=copy.deepcopy(S) for i in range(N-2): if S[i]=="o" and S[i+1]=="o" and S[i+2]=="-": print("O") flag=1 break if S[i]=="-" and S[i+1]=="o" and S[i+2]=="o": print("O") flag=1 break if S[i]=="o" and S[i+1]=="-" and S[i+2]=="o": print("O") flag=1 break if S[i]=="o" and S[i+1]=="o" and S[i+2]=="o": print("O") flag=1 break if flag: continue for i in range(N-3): if S[i]=="-" and S[i+1]=="o" and S[i+2]=="-" and S[i+3]=="-": print("O") flag=1 break if S[i]=="-" and S[i+1]=="-" and S[i+2]=="o" and S[i+3]=="-": print("O") flag=1 break if flag: continue for i in range(N-2): if S[i]=="o" and S[i+1]=="-" and S[i+2]=="-": S[i+1]="x" S[i+2]="o" for i in range(N-2): if S[i]=="o" and S[i+1]=="o" and S[i+2]=="-": print("O") flag=1 break if S[i]=="-" and S[i+1]=="o" and S[i+2]=="o": print("O") flag=1 break if S[i]=="o" and S[i+1]=="-" and S[i+2]=="o": print("O") flag=1 break if S[i]=="o" and S[i+1]=="o" and S[i+2]=="o": print("O") flag=1 break if flag: continue S=S2 for i in range(N-1,1,-1): if S[i]=="o" and S[i-1]=="-" and S[i-2]=="-": S[i-1]="x" S[i-2]="o" for i in range(N-2): if S[i]=="o" and S[i+1]=="o" and S[i+2]=="-": print("O") flag=1 break if S[i]=="-" and S[i+1]=="o" and S[i+2]=="o": print("O") flag=1 break if S[i]=="o" and S[i+1]=="-" and S[i+2]=="o": print("O") flag=1 break if S[i]=="o" and S[i+1]=="o" and S[i+2]=="o": print("O") flag=1 break if flag: continue print("X")