n = int(input()) kachi = ["ooo", "-oo", "oo-"] for _ in range(n): flag = 0 a, b = input().split() for word in kachi: if word in b: flag = 1 print("O" if flag else "X")