#include using namespace std; int q,t; char c; int main(){ cin >> q; stack st; stack history; while(q--){ cin >> t; if(t == 1){ cin >> c; st.push(c); if(st.size() >= 3){ char a = st.top(); st.pop(); char b = st.top(); st.pop(); char c = st.top(); st.pop(); if(a == ')' && b == '|' && c == '('){ history.push(1); } else { st.push(c); st.push(b); st.push(a); history.push(0); } } else { history.push(0); } } else{ int last = history.top(); history.pop(); if(last){ st.push('('); st.push('|'); } else{ st.pop(); } } cout << (st.empty() ? "Yes" : "No") << "\n"; } }