'''import sys
from numpy.core.defchararray import count
for line in sys.stdin:
a = line.split()
print(int(a[0]) + int(a[1]))'''
t=int(input())
for i in range(t):
ls=[]
str1=input()
if len(str1)==0:
print(str1)
for j in str1:
if j==')' and len(ls)!=0:
ls.pop()
else:
ls.append(j)
coun=len(ls)
if coun%2!=0:
print(-1)
elif len(str1)==2:
print('()')
else:
print('There are multiple solutions')

京公网安备 11010502036488号