#![allow(unused_imports)] #![allow(non_snake_case)] use std::cmp::*; use std::collections::*; use std::io::Write; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let n = read::(); for i in 0..n { let v = read_vec::(); let s = &v[1].chars().collect::>(); if s.len() < 3 { println!("X"); continue; } let mut found = false; for i in 0..s.len() - 2 { if s[i] == 'o' && s[i + 1] == 'o' && s[i + 2] == 'o' { found = true; } if s[i] == 'o' && s[i + 1] == 'o' && s[i + 2] == '-' { found = true; } if s[i] == '-' && s[i + 1] == 'o' && s[i + 2] == 'o' { found = true; } } for i in 0..s.len() - 3 { if s[i] == '_' && s[i + 1] == 'o' && s[i + 2] == '_' && s[i + 3] == '_' { found = true; } if s[i] == '_' && s[i + 1] == '_' && s[i + 2] == 'o' && s[i + 3] == '_' { found = true; } } let mut spans = vec![]; for i in 0..s.len() { if s[i] != '-' { continue; } if i == 0 || s[i - 1] != '-' { spans.push((i, i)); } else { let idx = spans.len() - 1; spans[idx].1 = i; } } for (start, end) in spans { if start == 0 || end == s.len() - 1 || (end - start) % 2 == 1 { continue; } if s[start - 1] == 'o' && s[end + 1] == 'o' { found = true; } } if found { println!("O"); } else { println!("X"); } } } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }