#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <stack>
using namespace std;
int main() {
freopen("input.txt", "rt", stdin);
int n;
scanf("%d", &n);
string str;
for (int i = 0; i < n; i++) {
cin >> str;
if (str[0] == ')') {
printf("NO\n");
continue;
}
int cnt = 0;
int flag = 1;
for (int j = 0; j < str.length(); j++) {
if (str[j] == '(') {
cnt++;
}
else if (str[j] == ')') {
cnt--;
}
if (cnt < 0) {
flag = 0;
}
}
if (flag == 1 && cnt==0) {
printf("YES\n");
}
else {
printf("NO\n");
}
}
return 0;
}