#include <bits/stdc++.h>
#define ll int long long
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
cin.tie(NULL);
   //cout << "Hello World" << endl; 
  int t;
  cin>>t;
  while(t--){
      string s;
      cin>>s;
      int c=0;
      int n=s.size();
      stack<char>st;
      for(int i=0;i<n;i++){
          if(s[i]=='('||s[i]=='?'){
              if(i==n-1&&s[i]=='('){
                  cout<<"NO";
                  c++;
                  break;
              }else st.push(s[i]);
          }else if(s[i]==')'){
              if(st.empty()){
                  c++;
                cout<<"NO";
                break;
              }else st.pop();
          }
      }
      if(c==0){
          if(st.size()%2==0){
              cout<<"YES";
          }else cout<<"NO";
      }
      cout<<endl;
  }
   return 0;
}