#include "bits/stdc++.h" #define REP(i,n,N) for(int i=(n); i<(N); i++) #define RREP(i,n,N) for(ll i=(N-1); i>=n; i--) #define CK(n,a,b) ((a)<=(n)&&(n)<(b)) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)< q[100010]; int main(){ cin>>N>>s; cnt[0]=1; REP(i,1,N){ if(s[i]=='('){ cnt[i]=cnt[i-1]+1; }else{ q[cnt[i-1]].push(i); cnt[i]=cnt[i-1]-1; } } REP(i,0,N){ if(s[i]=='('){ int op = q[cnt[i]].front(); ans[i]=op+1; ans[op]=i+1; q[cnt[i]].pop(); } } REP(i,0,N){ p(ans[i]); } }