n = int(eval(input()))

s = eval(input())

ans = s

while s.count("()")>0:

    s = s.replace("()", "")

cnt_l = s.count(")")

cnt_r = s.count("(")

ans = cnt_l * "(" + ans

ans += cnt_r * ")"

print(ans)
n = int(eval(input()))

s = eval(input())

ans = s

while s.count("()")>0:

    s = s.replace("()", "")

cnt_l = s.count(")")

cnt_r = s.count("(")

print((cnt_l * "(" + ans + cnt_r * ")"))
n = int(eval(input()))
s = eval(input())
ans = s
while s.count("()") > 0:
    s = s.replace("()", "")
cnt_l = s.count(")")
cnt_r = s.count("(")
ans = cnt_l * "(" + ans
ans += cnt_r * ")"
print(ans)

n = int(eval(input()))
s = eval(input())
ans = s
while s.count("()") > 0:
    s = s.replace("()", "")
cnt_l = s.count(")")
cnt_r = s.count("(")
print((cnt_l * "(" + ans + cnt_r * ")"))

-ans = cnt_l * "(" + ans -ans += cnt_r * ")" -print(ans) +print((cnt_l * "(" + ans + cnt_r * ")"))