#include using namespace std; using ll = long long; using ul = unsigned long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; string s; cin >> n >> s; vector v(n); stack st; for (int i = 0; i < n; ++i) { if (s[i] == '(') st.push(i); else { int pos = st.top(); v[i] = pos + 1; v[pos] = i + 1; st.pop(); } } stringstream ss; for (const auto& it : v) ss << it << "\n"; string res = ss.str(); cout << res; return 0; }