import sys input = sys.stdin.readline T=int(input()) Q=[list(input().split()[1]) for i in range(T)] for S in Q: N=len(S) flag=0 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-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 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") break if S[i]=="-" and S[i+1]=="o" and S[i+2]=="o": print("O") break if S[i]=="o" and S[i+1]=="-" and S[i+2]=="o": print("O") break if S[i]=="o" and S[i+1]=="o" and S[i+2]=="o": print("O") break else: print("X")