#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int Q; cin >> Q; vector> stk_hist; vector bad_hist; vector stk; // stack of pipe counts bool bad = false; stk_hist.push_back(stk); bad_hist.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(0); } else if (c == '|') { if (stk.empty()) bad = true; else stk.back()++; } else { // ')' if (stk.empty() || stk.back() != 1) bad = true; else stk.pop_back(); } } } else { stk = stk_hist.back(); bad = bad_hist.back(); stk_hist.pop_back(); bad_hist.pop_back(); // after popping, continue to output cout << (!bad && stk.empty() ? "Yes\n" : "No\n"); continue; } stk_hist.push_back(stk); bad_hist.push_back(bad); cout << (!bad && stk.empty() ? "Yes\n" : "No\n"); } return 0; }