import sys
from collections import Counter
T = int(input())
answer =''
for i in range(T):
li = list(map(str, sys.stdin.readline().rstrip()))
if(len(li) == 0):
answer += 'NO\n'
continue
counter = Counter(li)
if(counter['('] != counter[')']):
answer += 'NO\n'
continue
stack = []
for i in li:
if( i == '('):
stack.append(i)
else:
flag = True
while(stack != [] and flag):
pop = stack.pop()
if(pop == '('):
flag = False
if(stack == []):
answer += 'YES\n'
else :
answer += 'NO\n'
print(answer)