#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #define fi first #define se second #define rep(i,n) for(ll i=0;i<(n);i++) #define rrep(i,n) for(ll i=(n)-1;i>=0;i--) #define orep(i,n) for(ll i=1;i<=(n);i++) #define nfor(i,s,n) for(ll i=(s);i<(n);i++) #define dfor(i,s,n) for(ll i=(s)-1;i>=n;i--) #define INF 2e18//9223372036854775807 #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define chmax(x,y) x = max(x,y) #define chmin(x,y) x = min(x,y) #define pb push_back #define pob pop_back #define vc vector #define YES cout << "Yes" << endl; #define NO cout << "No" << endl; #define YN {cout << "Yes" << endl;}else{cout << "No" << endl;} #define dame cout << -1 << endl; #define vc_unique(v) v.erase(unique(v.begin(), v.end()), v.end()) #define vc_remove(v,x) v.erase(remove(v.begin(), v.end(),x), v.end()) #define vc_rotate(v) rotate(v.begin(), v.begin()+1, v.end()) #define pop_cnt(s) ll(popcount(uint64_t(s))) #define next_p(v) next_permutation(v.begin(),v.end()) #ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif using namespace std; //using namespace atcoder; using ll = long long; using ld = long double; using pll = pair; using vvvvvl = vector > > > >; using vvvvl = vector > > >; using vvvl = vector > >; using vvl = vector >; using vl = vector; using vb = vector; using vvb = vector >; using Graph = vector >; template using pq = priority_queue,less >; template using pq_g = priority_queue,greater >; ll dx[4] = {0,1,0,-1};ll ddx[8] = {1,1,0,-1,-1,-1,0,1}; ll dy[4] = {1,0,-1,0};ll ddy[8] = {0,1,1,1,0,-1,-1,-1}; bool out_grid(ll i, ll j, ll h, ll w){//trueならcontinueする return(!(0 <= i && i < h && 0 <= j && j 0){ if((1ll << cnt) & y){ y ^= (1ll << cnt); ans *= a; ans %= m; } a = a*a; a %= m; cnt++; } return ans; } ll npow(ll x,ll y){ ll a = x; ll cnt = 0; ll ans = 1; while(y > 0){ if((1ll << cnt) & y){ y ^= (1ll << cnt); ans *= a; } a = a*a; cnt++; } return ans; } void print(ld x){printf("%.20Lf\n", x);} //////////////////////////////////////////////////////////////// int main(){ ll Q; cin >> Q; vc> sta; vc> arr; ll cnt = 0; vvl group(1e6,vl(3,-1)); rep(i,Q){ ll ty; cin >> ty; if(ty == 1){ char c; cin >> c; sta.pb({c,arr.size()}); if(c == '('){ arr.pb({c,cnt}); cnt++; }else if(c == '|'){ arr.pb({c,-1}); }else{ arr.pb({c,-1}); } }else{ char x = arr[arr.size()-1].fi; ll g = arr[arr.size()-1].se; if(g == -1){ arr.pob(); sta.pob(); }else{ if(x == ')'){ sta.pb({'(',group[g][0]}); sta.pb({'|',group[g][1]}); group[g][2] = -1; arr[group[g][1]].se = -1; group[g][1] = -1; arr.pob(); }else if(x == '('){ group[g][0] = -1; arr.pob(); sta.pob(); cnt--; } } } while(sta.size() > 2){ if(sta[sta.size()-3].fi == '(' && sta[sta.size()-2].fi == '|' && sta[sta.size()-1].fi == ')'){ ll g = arr[sta[sta.size()-3].se].se; group[g][0] = sta[sta.size()-3].se; group[g][1] = sta[sta.size()-2].se; group[g][2] = sta[sta.size()-1].se; sta.pob(); sta.pob(); sta.pob(); arr[group[g][0]].se = g; arr[group[g][1]].se = g; arr[group[g][2]].se = g; }else{ break; } } if(sta.size() == 0)YN; } }