import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String s = sc.next(); Stack stack = new Stack(); int[] cor = new int[n]; for(int i = 0; i < n; i++) { char c = s.charAt(i); if(c == '(') { stack.push(i + 1); } else { int pos = stack.pop(); cor[pos] = i + 1; cor[i + 1] = pos; } } for(int i = 0; i < n; i++) { System.out.println(cor[i]); } } }