#include #define rep(i, n) for (lli i = 0; i < (n); i++) #define rrep(i, n) for (lli i = (n)-1; i >= 0; i--) using namespace std; using lli = long long int; int main() { stack st; int n; cin >> n; string s; cin >> s; int ans[2000005] = {}; rep(i, n) { if (s[i] == '(') st.push(i); else { ans[i] = st.top(); ans[st.top()] = i; st.pop(); } } rep(i, n) cout << ans[i] + 1 << endl; }