fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let n: Vec = s.split_whitespace().flat_map(str::parse).collect(); s.clear(); std::io::stdin().read_line(&mut s).ok(); let mut v = vec![]; s.chars().enumerate().for_each(|(i, c)| match c { '(' => v.push(i + 1), _ => { if let Some(j) = v.pop() { match n[1] { x if x == j => println!("{}", i + 1), x if x == i + 1 => println!("{}", j), _ => {} } } } }); }