#include #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; struct Action { int type; bool bad_prev; }; int main() { cin.tie(nullptr) -> sync_with_stdio(false); int q; cin >> q; vector st; vector hist; bool bad = false; rep(qi, q) { int t; cin >> t; if (t == 1) { char c; cin >> c; Action act; act.bad_prev = bad; act.type = 3; if (c == '(') { st.push_back(0); act.type = 0; } else if (c == '|') { if (st.size() and st.back() == 0) { st.back() = 1; act.type = 1; } else { bad = true; } } else { if (st.size() and st.back() == 1) { st.pop_back(); act.type = 2; } else { bad = true; } } hist.push_back(act); } else { Action act = hist.back(); hist.pop_back(); bad = act.bad_prev; if (act.type == 0) { st.pop_back(); } else if (act.type == 1) { st.back() = 0; } else if (act.type == 2) { st.push_back(1); } } if (!bad and !st.size()) puts("Yes"); else puts("No"); } return 0; }