rt
(freopen是我刚刚注释掉的
#include<bits/stdc++.h>
using namespace std;
stack<char> q;
string s;
int num[1010];
int n,p;
int main(){
//freopen("expr.in","r",stdin);
//freopen("expr.out","w",stdout);
getline(cin,s);
scanf("%d",&n);
int t;
for(int i=0;i<n;i++){
scanf("%d",&t);
num[i+1]=t;
}
scanf("%d",&p);
int x,y;
while(p--){
scanf("%d",&t);
num[t]=abs(num[t]-1);
for(int i=0;i<s.length();i++){
if(s[i]=='x'){
q.push(num[s[i+1]-'0']+'0');
continue;
}
if(s[i]=='&'){
x=q.top()-'0';q.pop();
y=q.top()-'0';q.pop();
//cout<<x<<" "<<y<<endl;
q.push(x&y+'0');
}
if(s[i]=='|'){
x=q.top()-'0';q.pop();
y=q.top()-'0';q.pop();
//cout<<x<<" "<<y<<endl;
q.push(x|y+'0');
}
if(s[i]=='!'){
x=int(q.top()-'0');q.pop();
q.push(abs(x-1));
}
}
printf("%d\n",q.top());
q.pop();
num[t]=abs(num[t]-1);
}
system("pause");
return 0;
}