#include using namespace std; int main(void){ int q; cin>>q; stackst; stackst2; int flag=-1,r1=0,r2=0; while(q--){ int op; cin>>op; if(op==1){ char c; cin>>c; st.push(c); if(c=='('){ if(flag==-1){ st2.push(1); } }else if(c=='|'){ if(flag==-1){ if(!st2.empty()&&st2.top()==1){ st2.pop(); st2.push(2); }else{ flag=st.size(); } } }else{ if(flag==-1){ if(!st2.empty()&&st2.top()==2){ st2.pop(); }else{ flag=st.size(); } } } }else{ if(st.top()=='('){ if(flag==-1){ if(!st2.empty()&&st2.top()==1){ st2.pop(); }else{ cerr<<"error!"<