#![allow(non_snake_case)] use std::io::{ self, prelude::* }; macro_rules! pick { ($tokens:expr) => { $tokens.next().unwrap().parse().expect("parse error") } } fn main() { let mut s = String::new(); io::stdin().read_to_string(&mut s).expect("i/o error"); let mut tokens = s.split_whitespace(); let N: usize = pick!(tokens); let S: String = pick!(tokens); let S: Vec<_> = S.chars().collect(); let mut stk = vec![]; let mut v = vec![9999999; N]; for (i,&c) in S.iter().enumerate() { match c { '(' => { stk.push(i); }, ')' => { let j = stk.pop().expect("stack underflow"); v[i] = j; v[j] = i; }, _ => panic!("unexpected char: {}", c), } } for i in 0..N { let ans = v[i] + 1; println!("{}", ans); } }