N = int(eval(input()))

S = eval(input())



l = 0

r = 0

for i in range(N):

    if S[i] == ")":

        r -= 1

        if r<0:

            l += 1

            r=0 #rを0に戻す作業

    else:

        r += 1



print(("("*l + S + ")"*r))
N = int(eval(input()))

S = eval(input())



l = 0

r = 0

for i in range(N):

    if S[i]==")":

        r -= 1

        if r<0:

            l += 1

            r = 0

    else:

        r += 1



ans = "("*l + S + ")"*r



print(ans)
N = int(eval(input()))
S = eval(input())
l = 0
r = 0
for i in range(N):
    if S[i] == ")":
        r -= 1
        if r < 0:
            l += 1
            r = 0  # rを0に戻す作業
    else:
        r += 1
print(("(" * l + S + ")" * r))

N = int(eval(input()))
S = eval(input())
l = 0
r = 0
for i in range(N):
    if S[i] == ")":
        r -= 1
        if r < 0:
            l += 1
            r = 0
    else:
        r += 1
ans = "(" * l + S + ")" * r
print(ans)

-            r = 0  # rを0に戻す作業 +            r = 0 -print(("(" * l + S + ")" * r)) +ans = "(" * l + S + ")" * r +print(ans)