gets.to_i.times do n,s = gets.chomp.split puts s =~ /ooo|-oo|oo-|o-o|-(?:o-|-o)-/ ? 'O' : 'X' end