import sys

T = int(sys.stdin.readline())

# '('랑 ')' 숫자 같으면 YES 출력되게
for i in range(T):
  list = sys.stdin.readline()
  for j in list:
    left="("
    right=")"
  if(list.count(left)==list.count(right)):
    print("YES")
  else:
    print("NO")
  
7e3cc986d45730fcdfb88367cf493bb8331991ee
<mask token>

<mask token>
for i in range(T):
    list = sys.stdin.readline()
    for j in list:
        left = '('
        right = ')'
    if list.count(left) == list.count(right):
        print('YES')
    else:
        print('NO')

<mask token>
T = int(sys.stdin.readline())
for i in range(T):
    list = sys.stdin.readline()
    for j in list:
        left = '('
        right = ')'
    if list.count(left) == list.count(right):
        print('YES')
    else:
        print('NO')

import sys
T = int(sys.stdin.readline())
for i in range(T):
    list = sys.stdin.readline()
    for j in list:
        left = '('
        right = ')'
    if list.count(left) == list.count(right):
        print('YES')
    else:
        print('NO')

import sys

T = int(sys.stdin.readline())

# '('랑 ')' 숫자 같으면 YES 출력되게
for i in range(T):
  list = sys.stdin.readline()
  for j in list:
    left="("
    right=")"
  if(list.count(left)==list.count(right)):
    print("YES")
  else:
    print("NO")
  