N = int(eval(input()))

S = eval(input())

T = S



for n in range(N):

  T = T.replace("()","")



L = T.count("(")

R = T.count(")")

S = R*"("+S+L*")"

print(S)
N = int(eval(input()))

S = T = eval(input())



while "()" in S:

  S = S.replace("()","")



print(("("*S.count(")")+T+S.count("(")*")"))
N = int(eval(input()))
S = eval(input())
T = S
for n in range(N):
    T = T.replace("()", "")
L = T.count("(")
R = T.count(")")
S = R * "(" + S + L * ")"
print(S)

N = int(eval(input()))
S = T = eval(input())
while "()" in S:
    S = S.replace("()", "")
print(("(" * S.count(")") + T + S.count("(") * ")"))

-S = eval(input()) -T = S -for n in range(N): -    T = T.replace("()", "") -L = T.count("(") -R = T.count(")") -S = R * "(" + S + L * ")" -print(S) +S = T = eval(input()) +while "()" in S: +    S = S.replace("()", "") +print(("(" * S.count(")") + T + S.count("(") * ")"))