import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
public class Main {
static String pro(String s) {
Stack<Character> stack = new Stack();
for (char c : s.toCharArray()) {
if (c == '(') {
stack.push(c);
} else if (c == ')') {
if (!stack.isEmpty() && stack.pop() == '(') {
continue;
} else {
return "NO";
}
}
}
if (!stack.isEmpty()) {
return "NO";
}
return "YES";
}
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int T = Integer.parseInt(br.readLine());
for (int i = 0; i < T; i++) {
String input = br.readLine();
String result = pro(input);
sb.append(result).append('\n');
}
System.out.println(sb.toString());
}
}