#include #include using namespace std; struct Node { char c; int prev; int size; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int Q; cin >> Q; vector nodes = {{'\0', -1, 0}}; vector history = {0}; while (Q--) { int type; cin >> type; if (type == 1) { char c; cin >> c; int cur = history.back(); if (c == ')' && nodes[cur].size >= 2 && nodes[cur].c == '|' && nodes[nodes[cur].prev].c == '(') { history.push_back(nodes[nodes[cur].prev].prev); } else { history.push_back(nodes.size()); nodes.push_back({c, cur, nodes[cur].size + 1}); } } else { history.pop_back(); } cout << (nodes[history.back()].size == 0 ? "Yes" : "No") << "\n"; } return 0; }