#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; string s; cin >> n >> s; vector ans(n); stack st; rep(i, n) { if (s[i] == '(') { st.push(i); } else { int l = st.top(); st.pop(); ans[l] = i, ans[i] = l; } } rep(i, n) cout << ans[i] + 1 << '\n'; return 0; }