#include using namespace std; struct Frame { bool left_ok; bool has_pipe; bool right_ok; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int Q; cin >> Q; vector> hist_stk; vector hist_bad; vector stk; bool bad = false; hist_stk.push_back(stk); hist_bad.push_back(bad); for (int i = 0; i < Q; i++) { int t; cin >> t; if (t == 1) { char c; cin >> c; if (!bad) { if (c == '(') { stk.push_back({true, false, true}); } else if (c == '|') { if (stk.empty() || stk.back().has_pipe) { bad = true; } else { stk.back().has_pipe = true; } } else { // ')' if (stk.empty()) { bad = true; } else { Frame f = stk.back(); stk.pop_back(); if (!f.has_pipe) { bad = true; } else { // reduce this frame into a valid unit if (!stk.empty()) { if (!stk.back().has_pipe) stk.back().left_ok &= true; else stk.back().right_ok &= true; } } } } } } else { stk = hist_stk.back(); bad = hist_bad.back(); hist_stk.pop_back(); hist_bad.pop_back(); cout << (!bad && stk.empty() ? "Yes\n" : "No\n"); continue; } hist_stk.push_back(stk); hist_bad.push_back(bad); cout << (!bad && stk.empty() ? "Yes\n" : "No\n"); } return 0; }