#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#define N 100005
using namespace std;

int t,l,ans,flag,ll,rr,hh;
char c[1000];

int main()
{
	//freopen("1.in","r",stdin);
	scanf("%d ",&t);
	while (t--)
	{
		scanf("%s",c+1);
		l=strlen(c+1);
		ans=flag=0;ll=rr=0;
		if (l%2==1) flag=1;
		for (int i=1; i<=l ;i++)
		{
			if (c[i]=='(') ll++;
			if (c[i]==')') rr++;
		}
		hh=l/2-ll;
		for (int i=1; i<=l; i++)
		{
			if (c[i]==')')
			{
				if (ans==0) flag=1;
				else ans--;
			}
			else
			if (c[i]=='(')
			{
				ans++;
			}
			else
			{
				if (hh)
				{
					hh--;
					ans++;
				}
				else
				{
					ans--;
					if (ans<0) flag=1;
				}
			}
		}
		if (flag) printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}
