#include #include #include void solve() { int n; std::string s; std::cin >> n >> s; std::vector stk; std::vector ans(n); for (int i = 0; i < n; ++i) { if (s[i] == '(') { stk.push_back(i); } else { int j = stk.back(); stk.pop_back(); ans[i] = j, ans[j] = i; } } for (auto i : ans) std::cout << i + 1 << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }