#include<bits/stdc++.h> #define rep(i,a,b) for(int i=a;i<b;i++) using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } //--------------------------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------------------------- ∧_∧ ∧_∧ (´<_` ) Welcome to My Coding Space! ( ´_ゝ`) / ⌒i / \ | | / / ̄ ̄ ̄ ̄/ | __(__ニつ/ _/ .| .|____ \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int N; string S; int ans[201010]; //--------------------------------------------------------------------------------------------------- void _main() { cin >> N >> S; stack<int> s; rep(i, 0, N) { if (S[i] == '(') s.push(i); else { int j = s.top(); s.pop(); ans[i] = j; ans[j] = i; } } rep(i, 0, N) printf("%d\n", ans[i] + 1); }