#include void push(int x,int *p,int a[]){ int m; m = *p; a[m] = x; m++; *p = m; } int pop(int *p,int a[]){ int m; m = *p; m--; *p = m; return a[m]; } int main(void){ int n,p=0,a[262144],m[262144],i,pp; char s[262144]; scanf("%d%s",&n,s); for(i = 1;i <= n;i++){ if(s[i-1] == '('){push(i,&p,a);} else{ pp = pop(&p,a); m[pp] = i; m[i] = pp; } } for(i = 1;i <= n;i++){printf("%d\n",m[i]);} return 0; }