#include int top = 0, stack[100000]; void push(int i) { stack[top] = i; ++top; } int pop(void) { --top; return stack[top]; } int main(void) { char S[200001]; int N, ans[200000], tmp, i; scanf("%d%s", &N, S); for (i = 0; i < N; ++i) { if (S[i] == '(') push(i); else { tmp = pop(); ans[i] = tmp + 1; ans[tmp] = i + 1; } } for (i = 0; i < N; ++i) printf("%d\n", ans[i]); return 0; }