#include #include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template bool chmin(T& x, T y) { return x > y ? (x = y, true) : false; } template bool chmax(T& x, T y) { return x < y ? (x = y, true) : false; } using mint = atcoder::modint998244353; struct d_stack { vector v; vector> hist; d_stack() {}; void add(char c) { int f = 0; if (c == '(') { v.push_back(1); } else if (c == '|') { if (!v.empty() && v.back() == 1) v.back()++, f = 1; else v.push_back(-1); } else { if (!v.empty() && v.back() == 2) v.pop_back(), f = 1; else v.push_back(-1); } hist.push_back({c, f}); } void rollback() { auto [c, f] = hist.back(); hist.pop_back(); if (c == '(') { assert(v.back() == 1); v.pop_back(); } else if (c == '|') { assert(!v.empty()); if (f) { assert(v.back() == 2); v.back()--; } else { assert(v.back() == -1); v.pop_back(); } } else { if (f) { v.push_back(2); } else { assert(v.back() == -1); v.pop_back(); } } } bool check() { return v.empty(); } }; void solve() { int q; cin >> q; d_stack v; while (q--) { int t; cin >> t; if (t == 1) { char c; cin >> c; v.add(c); } else v.rollback(); if (v.check()) cout << "Yes\n"; else cout << "No\n"; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); int t = 1; // cin >> t; while (t--) solve(); }