Open SHyeonL opened 1 year ago
T = int(input())
for i in range(T):
string = input()
cnt = 0
s = []
for j in string:
if j == "(":
s.append(j)
cnt += 1
else:
if len(s)!=0:
s.pop()
cnt += 1
else:
break
if len(s)==0 and cnt == len(string):
print("YES")
else:
print("NO")