import array def main(): N = int(input()) S = input() D = [] d = 1 for s in S: if s == "(": D.append(d) d += 1 else: d -= 1 D.append(d) idx_stack = array.array("q", []) depth_stack = array.array("q", [-1]) correspond = array.array("q", [-1] * N) for idx, depth in enumerate(D): idx_stack.append(idx) depth_stack.append(depth) if depth_stack[-1] == depth_stack[-2]: start = idx_stack[-2] end = idx_stack[-1] correspond[start] = end correspond[end] = start idx_stack = idx_stack[:-2] depth_stack = depth_stack[:-2] for c in correspond: print(c+1) main()