#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; string S; cin >> N >> S; stack st; vector ans(N, -1); rep(i,N) { if(S[i] == '(') st.push(i); else { int x = st.top(); st.pop(); ans[x] = i; ans[i] = x; } } rep(i,N) cout << ans[i] + 1 << "\n"; }