/**
 * @(#)ParenMatch.java
 *
 *
 * @Casey Jenks
 * @version 1.00 2007/7/25
 */
import java.io.*;
import java.util.*;

public class match {
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception{
        int i, j, n, openCnt, closeCnt;
        Boolean valid;
        String strWord;
        Scanner stdin;
               
        stdin = new Scanner(new File("match.in"));
        n = stdin.nextInt();
        stdin.nextLine();
        
        //loop through n times and 
        for (i = 0; i < n; i++){
        	openCnt = 0;
        	closeCnt = 0;
        	strWord = stdin.nextLine();
        	valid = true;
        	
        	//loop through string and count the number of occurrences of '(' and ')'
        	for (j = 0; j < strWord.length(); j++){

        		if (strWord.charAt(j) == '(')
        			openCnt++;
        		
        		else if (strWord.charAt(j) == ')')
        			closeCnt++;
        		
        		//if the #closed parenthesis becomes greater than #open parenthesis, then it is not valid.
        		if (closeCnt > openCnt){
        			valid = false;
        			j = strWord.length();
        		}		
        	}
        	
        	//if the #open and #closed do not match up, then it is not valid
        	if (openCnt != closeCnt)
        		valid = false;
        	        	
        	//print answer
        	if (valid == true)
        		System.out.println("yes");
        	else
        		System.out.println("no");
        }
        
        stdin.close();
    }
}
