import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] arr = sc.next().toCharArray(); ArrayDeque stack = new ArrayDeque<>(); int[] ans = new int[n]; for (int i = 0; i < n; i++) { if (arr[i] == '(') { stack.push(i); } else { int j = stack.pop(); ans[i] = j; ans[j] = i; } } StringBuilder sb = new StringBuilder(); for (int x : ans) { sb.append(x + 1).append("\n"); } System.out.print(sb); } }