
n = int(input())
for _ in range(n):
bracket = list(input())
stack = [] # 빈 스택 생성
isEmpty = False
for i in range(len(bracket)):
if bracket[i] == "(": # 열린 괄호일 경우
stack.append(bracket[i]) # 스택에 집어넣기
else: # 닫힌 괄호일 경우
if not stack: # 스택이 비어있으면
isEmpty = True # True 처리
break
else: # 스택이 비어있지 않으면
stack.pop()
if not stack and not isEmpty:
print("YES")
else:
print("NO")