#include<bits/stdc++.h>
using namespace std ;
const int N=4e5;
string str;
int node[4*N+5];
void build(int i , int j , int index)
{
if(i==j)
{
if(str[i]=='(')
{
node[index]=1;
}
else
{
node[index]=-1;
}
return ;
}
int mid=(i+j)/2;
build(i,mid,2*index);
build(mid+1,j,2*index+1);
node[index]=node[2*index]+node[2*index+1];
return ;
}
void update(int i , int j , int index, int k)
{
if(j<k||i>k)
return ;
if(i==j&&i==k)
{
if(node[index]==1)
node[index]=-1;
else
node[index]=1;
return ;
}
int mid=(i+j)/2;
update(i,mid,2*index,k);
update(mid+1,j,2*index+1,k);
node[index]=node[2*index]+node[2*index+1];
return ;
}
int main ()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t =10;
int a=1;
while(t--)
{
int n ;
cin >> n ;
cin >> str ;
build(0,n-1,1);
cout<<"TEST "<<a<<":"<<"\n";
int m ;
cin >> m ;
while(m--)
{
int k;
cin >> k ;
if(k==0)
{
if(node[1]==0&&node[2]>=0&&node[3]<=0)
cout<<"YES"<<"\n";
else
cout<<"NO"<<"\n";
}
else
update(0,n-1,1,k-1);
}
a++;
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZCA7CmNvbnN0IGludCBOPTRlNTsKc3RyaW5nIHN0cjsKaW50IG5vZGVbNCpOKzVdOwp2b2lkIGJ1aWxkKGludCBpICwgaW50IGogLCBpbnQgaW5kZXgpCnsKCWlmKGk9PWopCgl7CgkJaWYoc3RyW2ldPT0nKCcpCgkJewoJCW5vZGVbaW5kZXhdPTE7CgkJfQoJCWVsc2UKCQl7CgkJbm9kZVtpbmRleF09LTE7CgkJfQoJCXJldHVybiA7Cgl9CglpbnQgbWlkPShpK2opLzI7CglidWlsZChpLG1pZCwyKmluZGV4KTsKCWJ1aWxkKG1pZCsxLGosMippbmRleCsxKTsKCW5vZGVbaW5kZXhdPW5vZGVbMippbmRleF0rbm9kZVsyKmluZGV4KzFdOwoJcmV0dXJuID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