#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define rd(a) cin>>a
#define pt(a) cout<<a
#define pb push_back
#define mp make_pair
#define cl endl
#define ifor(i,a,b) for(i=a;i<=b;i++)
#define dfor(i,a,b) for(i=a;i>=b;i--)
#define pii pair<int,int>
#define sz 100000
#define mad 1000000007
struct nod {
int ob;
int cb;
};
struct nod tree[4*sz +5];
char a[sz+5];
int n;
void build(int node,int s,int e) {
if(s==e) {
if(a[s]=='(') {
tree[node].ob=1;
tree[node].cb=0;
}
else {
tree[node].ob=0;
tree[node].cb=1;
}
}
else {
int mid=(s+e)/2;
build(2*node,s,mid);
build(2*node +1,mid+1,e);
int mb=min(tree[2*node].ob,tree[2*node +1].cb);
tree[node].ob=tree[2*node].ob + tree[2*node +1].ob -mb;
tree[node].cb=tree[2*node].cb + tree[2*node +1].cb -mb;
}
}
void update(int node,int s,int e,int idx) {
if(s==idx) {
if(a[s]==')') {
tree[node].ob=1;
tree[node].cb=0;
a[s]='(';
}
else {
tree[node].ob=0;
tree[node].cb=1;
a[s]=')';
}
}
else {
int mid=(s+e)/2;
if(s<=idx && idx<=mid) {
update(2*node,s,mid,idx);
}
else {
update(2*node +1,mid+1,e,idx);
}
int mb=min(tree[2*node].ob,tree[2*node +1].cb);
tree[node].ob=tree[2*node].ob + tree[2*node +1].ob -mb;
tree[node].cb=tree[2*node].cb + tree[2*node +1].cb -mb;
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
int i,j,k;
string s;
t=10;
for(k=1;k<=t;k++) {
cin>>n;
cin>>s;
n=s.size();
//cout<<"s="<<s<<"\n";
for(i=0;i<n;i++) {
if(s[i]==')') {
a[i+1]=s[i];
}
else {
a[i+1]=s[i]; // if(s[i]=='(')
}
}
build(1,1,n);
cout<<"Test "<<k<<":"<<"\n";
int q,d;cin>>q;
while(q--) {
cin>>d;
if(d!=0) {
update(1,1,n,d);
}
else {
if(tree[1].ob==0 && tree[1].cb==0) cout<<"YES\n";
else cout<<"NO\n";
}
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiNkZWZpbmUgICAgbGwgICAgICAgICAgICAgIGxvbmcgbG9uZyBpbnQKI2RlZmluZSAgICByZChhKSAgICAgICAgICAgY2luPj5hCiNkZWZpbmUgICAgcHQoYSkgICAgICAgICAgIGNvdXQ8PGEKI2RlZmluZSAgICBwYiAgICAgICAgICAgICAgcHVzaF9iYWNrCiNkZWZpbmUgICAgbXAgICAgICAgICAgICAgIG1ha2VfcGFpcgojZGVmaW5lICAgIGNsICAgICAgICAgICAgICBlbmRsCiNkZWZpbmUgICAgaWZvcihpLGEsYikgICAgIGZvcihpPWE7aTw9YjtpKyspCiNkZWZpbmUgICAgZGZvcihpLGEsYikgICAgIGZvcihpPWE7aT49YjtpLS0pCiNkZWZpbmUgICAgcGlpICAgICAgICAgICAgIHBhaXI8aW50LGludD4KI2RlZmluZSAgICBzeiAgICAgICAgICAgICAgMTAwMDAwCiNkZWZpbmUgICAgbWFkICAgICAgICAgICAgIDEwMDAwMDAwMDcKCnN0cnVjdCBub2QgewogICAgCiAgICBpbnQgb2I7CiAgICBpbnQgY2I7Cn07CgpzdHJ1Y3Qgbm9kIHRyZWVbNCpzeiArNV07CmNoYXIgYVtzeis1XTsKaW50IG47Cgp2b2lkIGJ1aWxkKGludCBub2RlLGludCBzLGludCBlKSB7CiAgICAKICAgIGlmKHM9PWUpIHsKICAgICAgICAKICAgICAgICBpZihhW3NdPT0nKCcpIHsKICAgICAgICAgICAgCiAgICAgICAgICAgIHRyZWVbbm9kZV0ub2I9MTsKICAgICAgICAgICAgdHJlZVtub2RlXS5jYj0wOwogICAgICAgIH0KICAgICAgICBlbHNlIHsKICAgICAgICAgICAgdHJlZVtub2RlXS5vYj0wOwogICAgICAgICAgICB0cmVlW25vZGVdLmNiPTE7CiAgICAgICAgfQogICAgfQogICAgZWxzZSB7CiAgICAgICAgCiAgICAgICAgaW50IG1pZD0ocytlKS8yOwogICAgICAgIAogICAgICAgIGJ1aWxkKDIqbm9kZSxzLG1pZCk7CiAgICAgICAgYnVpbGQoMipub2RlICsxLG1pZCsxLGUpOwogICAgICAgIAogICAgICAgIGludCBtYj1taW4odHJlZVsyKm5vZGVdLm9iLHRyZWVbMipub2RlICsxXS5jYik7CiAgICAgICAgCiAgICAgICAgdHJlZVtub2RlXS5vYj10cmVlWzIqbm9kZV0ub2IgKyB0cmVlWzIqbm9kZSArMV0ub2IgLW1iOwogICAgICAgIHRyZWVbbm9kZV0uY2I9dHJlZVsyKm5vZGVdLmNiICsgdHJlZVsyKm5vZGUgKzFdLmNiIC1tYjsKICAgIH0KfQoKdm9pZCB1cGRhdGUoaW50IG5vZGUsaW50IHMsaW50IGUsaW50IGlkeCkgewogICAgCiAgICBpZihzPT1pZHgpIHsKICAgICAgICAKICAgICAgICBpZihhW3NdPT0nKScpIHsKICAgICAgICAgICAgCiAgICAgICAgICAgIHRyZWVbbm9kZV0ub2I9MTsKICAgICAgICAgICAgdHJlZVtub2RlXS5jYj0wOwogICAgICAgICAgICBhW3NdPScoJzsKICAgICAgICB9CiAgICAgICAgZWxzZSB7CiAgICAgICAgICAgIAogICAgICAgICAgICB0cmVlW25vZGVdLm9iPTA7CiAgICAgICAgICAgIHRyZWVbbm9kZV0uY2I9MTsKICAgICAgICAgICAgYVtzXT0nKSc7CiAgICAgICAgfQogICAgfQogICAgZWxzZSB7CiAgICAgICAgCiAgICAgICAgaW50IG1pZD0ocytlKS8yOwogICAgICAgIAogICAgICAgIGlmKHM8PWlkeCAmJiBpZHg8PW1pZCkgewogICAgICAgICAgICB1cGRhdGUoMipub2RlLHMsbWlkLGlkeCk7CiAgICAgICAgfQogICAgICAgIGVsc2UgewogICAgICAgICAgICB1cGRhdGUoMipub2RlICsxLG1pZCsxLGUsaWR4KTsKICAgICAgICB9CiAgICAgICAgCiAgICAgICAgaW50IG1iPW1pbih0cmVlWzIqbm9kZV0ub2IsdHJlZVsyKm5vZGUgKzFdLmNiKTsKICAgICAgICAKICAgICAgICB0cmVlW25vZGVdLm9iPXRyZWVbMipub2RlXS5vYiArIHRyZWVbMipub2RlICsxXS5vYiAtbWI7CiAgICAgICAgdHJlZVtub2RlXS5jYj10cmVlWzIqbm9kZV0uY2IgKyB0cmVlWzIqbm9kZSArMV0uY2IgLW1iOwogICAgfQp9CmludCBtYWluKCkgewogICAgCiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKTsKICAgIGNvdXQudGllKDApOwogICAgCiAgICBpbnQgdDsKICAgIGludCBpLGosazsKICAgIAogICAgc3RyaW5nIHM7CiAgICB0PTEwOwogICAgZm9yKGs9MTtrPD10O2srKykgewogICAgICAgIAogICAgICAgIGNpbj4+bjsKICAgICAgICBjaW4+PnM7CiAgICAgICAgbj1zLnNpemUoKTsKICAgICAgICAKICAgICAgICAvL2NvdXQ8PCJzPSI8PHM8PCJcbiI7CiAgICAgICAgCiAgICAgICAgZm9yKGk9MDtpPG47aSsrKSB7CiAgICAgICAgICAgIAogICAgICAgICAgICBpZihzW2ldPT0nKScpIHsKICAgICAgICAgICAgICAgIGFbaSsxXT1zW2ldOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgYVtpKzFdPXNbaV07ICAgICAvLyBpZihzW2ldPT0nKCcpCiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgYnVpbGQoMSwxLG4pOwogICAKICAgCiAgICAgICAgY291dDw8IlRlc3QgIjw8azw8IjoiPDwiXG4iOwogICAgICAgIGludCBxLGQ7Y2luPj5xOwogICAgICAgIHdoaWxlKHEtLSkgewogICAgICAgICAgICAKICAgICAgICAgICAgY2luPj5kOwogICAgICAgICAgICBpZihkIT0wKSB7CiAgICAgICAgICAgICAgICB1cGRhdGUoMSwxLG4sZCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIGlmKHRyZWVbMV0ub2I9PTAgJiYgdHJlZVsxXS5jYj09MCkgY291dDw8IllFU1xuIjsKICAgICAgICAgICAgICAgIGVsc2UgY291dDw8Ik5PXG4iOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgCiAgICByZXR1cm4gMDsKfQ==