import sys # input = lambda: sys.stdin.buffer.readline() input = lambda: sys.stdin.readline().rstrip() mi = lambda: map(int, input().split()) li = lambda: list(mi()) from collections import deque n = int(input()) st = deque() ans = [0] * n for i, c in enumerate(list(input())): if c == "(": st.append(i) else: j = st.pop() ans[i] = j + 1 ans[j] = i + 1 for x in ans: print(x)