#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int d=0;
int main()
{
    freopen("NGOAC .inp","r",stdin);
    freopen("NGOAC.out","w",stdout);
    cin>>n;
    for (int i=0;i<n;i++)
    {
        getline(cin,s);
        for (int j=0;j<s.size();j++)
        {
            if (s[j]=='(') d++;
            else if (s[j]==')') d--;
            if (d<0) break;
        }
        if (d==0) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        d=0;
    }
}
