#include using namespace std; long long gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } long long lcm(long long x, long long y) { if (x == 0 || y == 0) return 0; return x / gcd(x, y) * y; } int main() { int N; cin >> N; string S; cin >> S; map mp; stack st; for (int i = 0; i < N; i++) { if (S[i] == '(') { st.push(i); } else { int tmp = st.top(); mp[tmp] = i; mp[i] = tmp; st.pop(); } } for (int i = 0; i < N; i++) { cout << mp[i] + 1 << endl; } }