#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; string S; cin >> S; vector res(N, 0); stack> st; for (int i = 0; i < N; i++) { if (st.empty()) { st.push(make_pair(S[i], i)); } else { if (st.top().first == '(' && S[i] == ')') { int s = st.top().second; st.pop(); res[s] = i; res[i] = s; } else { st.push(make_pair(S[i], i)); } } } for (const auto &e : res) { cout << e + 1 << '\n'; } return 0; }