실버4 문제
T = int(input())
for _ in range(T):
k = input()
while True:
before = len(k)
k = k.replace('()', "")
after = len(k)
if (before == after):
break
if (len(k) == 0):
print('YES')
else:
print('NO')