#include typedef long long ll; using namespace std; int INF = 1LL << 30; int MOD = 1e9+7; main(){ int N; string S; cin >> N >> S; vector V(N); stack s; for(int i = 0;i < N;i++){ if(S[i] == '(')s.push(i); else{ int num = s.top(); s.pop(); V[num] = i; V[i] = num; } } for(auto i:V)cout << i+1 << endl; }