#include using namespace std; struct Node { char c; int prev; }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int Q; cin >> Q; vector nodes; nodes.reserve(3 * Q); vector history; history.reserve(Q + 1); int top = -1; // empty history.push_back(top); for (int i = 0; i < Q; i++) { int t; cin >> t; if (t == 1) { char c; cin >> c; // push new node nodes.push_back({c, top}); top = (int)nodes.size() - 1; // try reduce "(|)" if (top != -1) { int a = top; int b = nodes[a].prev; if (b != -1) { int c2 = nodes[b].prev; if (c2 != -1) { if (nodes[c2].c == '(' && nodes[b].c == '|' && nodes[a].c == ')') { // remove 3 nodes top = nodes[c2].prev; } } } } } else { // undo history.pop_back(); top = history.back(); cout << (top == -1 ? "Yes\n" : "No\n"); continue; } history.push_back(top); cout << (top == -1 ? "Yes\n" : "No\n"); } return 0; }