#!/usr/bin/env python import collections def check_brackets(s): n = len(s) res = [-1 for _ in range(n)] stack = collections.deque() for i, c in enumerate(s): if c == '(': stack.append(i) else: j = stack.pop() res[i] = j res[j] = i return res def main(): _ = input() s = input() res = check_brackets(s) print(*(r + 1 for r in res), sep="\n") if __name__ == '__main__': main()