#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int Q; cin >> Q; vector hist; string s = ""; hist.push_back(s); for (int i = 0; i < Q; i++) { int t; cin >> t; if (t == 1) { char c; cin >> c; s.push_back(c); // reduction while (s.size() >= 3) { int n = s.size(); if (s[n-3] == '(' && s[n-2] == '|' && s[n-1] == ')') { s.pop_back(); s.pop_back(); s.pop_back(); } else break; } hist.push_back(s); } else { hist.pop_back(); s = hist.back(); } cout << (s.empty() ? "Yes\n" : "No\n"); } return 0; }