#include using namespace std; using ll = long long; const ll INF = 1ll << 60; #define REP(i, n) for(ll i =0; i < ll(n); i++) template using V = vector; template bool chmax(A& a, B b) { return a bool chmin(A& a, B b) { return b stk; stack real; int invalid = 0; int q; cin >> q; REP(t, q) { int op; cin >> op; if(op == 1) { char c; cin >> c; real.push(c); if(invalid > 0) { invalid++; } else if(c == '(') { stk.push('('); } else if(c == '|') { if(!stk.empty() && stk.top() == '(') stk.top() = '|'; else invalid++; } else if(c == ')') { if(!stk.empty() && stk.top() == '|') stk.pop(); else invalid++; } } else { char c = real.top(); real.pop(); if(invalid > 0) invalid--; else { if(c == '(') { assert(stk.top() == '('); stk.pop(); } else if(c == '|') { assert(stk.top() == '|'); stk.top() = '('; } else if(c == ')') { stk.push('|'); } } } if(invalid == 0 && stk.empty()) { cout << "Yes\n"; } else { cout << "No\n"; } } } int main() { cin.tie(0)->sync_with_stdio(0); testcase(); }