import java.util.ArrayDeque; import java.util.Deque; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int N = scan.nextInt(); String S = scan.next(); scan.close(); Deque stack = new ArrayDeque(); int[]C = new int[N]; for(int i = 0; i < N; i++) { char c = S.charAt(i); if(c == '(') { stack.push(i); }else { int k = stack.pop(); C[i] = k + 1; C[k] = i + 1; } } for(int i : C) { System.out.println(i); } } }