https://www.acmicpc.net/problem/9012
N = int(input())
for i in range(N):
check = input()
left=0
right=0
no=0
for j in range(len(check)):
if check[j] == "(":
left+=1
else:
right+=1
if left<right:
no=1
break
if no==1:
print("NO")
elif left == right:
print("YES")
else:
print("NO")
a = int(input())
for i in range(a):
b = input()
s = list(b)
sum = 0
for i in s:
if i == '(':
sum += 1
elif i == ')':
sum -= 1
if sum < 0:
print('NO')
break
if sum > 0:
print('NO')
elif sum == 0:
print('YES')