# your code goes here
a = []
b = []
c = int(input())
d = 0
e = 0
response1 = ""
for i in range(c):
    text = input()
    try:
        for j in range(len(text)):
            if text[j] =="("  and d >= e :
                d += 1
            elif text[j] ==")"  and d < e:
                response = "NO"
            else:
                e += 1
                if d == e:
                    response = "YES"
                else:
                    response = "NO"
        d = 0
        e = 0
        response1 += response + "\n"
    except:
        response1 += "NO" + "\n"
print(response1.strip())