#include using namespace std; int main() { int Q; cin >> Q; vector stk; struct Op { int type; char val; char new_val; }; vector ops; for (int i = 0; i < Q; i++) { int t; cin >> t; if (t == 1) { char c; cin >> c; if (c == '(') { stk.push_back('('); ops.push_back({0, '(', 0}); } else if (c == '|') { if (!stk.empty() && stk.back() == '(') { stk.back() = 'M'; ops.push_back({2, '(', 'M'}); } else { stk.push_back('|'); ops.push_back({0, '|', 0}); } } else { if (!stk.empty() && stk.back() == 'M') { stk.pop_back(); ops.push_back({1, 'M', 0}); } else { stk.push_back(')'); ops.push_back({0, ')', 0}); } } } else { Op last = ops.back(); ops.pop_back(); if (last.type == 0) stk.pop_back(); else if (last.type == 1) stk.push_back(last.val); else stk.back() = last.val; } cout << (stk.empty() ? "Yes" : "No") << endl; } return 0; }