import typing class FenwickTree: '''Reference: https://en.wikipedia.org/wiki/Fenwick_tree''' def __init__(self, n: int = 0) -> None: self._n = n self.data = [0] * n def add(self, p: int, x: typing.Any) -> None: assert 0 <= p < self._n p += 1 while p <= self._n: self.data[p - 1] += x p += p & -p def sum(self, left: int, right: int) -> typing.Any: assert 0 <= left <= right <= self._n return self._sum(right) - self._sum(left) def _sum(self, r: int) -> typing.Any: s = 0 while r > 0: s += self.data[r - 1] r -= r & -r return s q=int(input()) p=k1=k2=0 ng=FenwickTree(q+1) t=[] for _ in range(q): k,*c=input().split() if k=='1': c=c[0] t+=c, p+=1 if c=='(': k1+=1 if c=='|': k2+=1 if ng.sum(p,p+1)==0: if k1<-(-p//3) or k2<-(-(p-1)//3)or k2>k1: ng.add(p,1) else: p-=1 c=t.pop() if c=='(': k1-=1 if c=='|': k2-=1 if ng.sum(p+1,p+2): ng.add(p+1,-1) if k1==k2==p-(k1+k2) and ng.sum(0,p+1)<1: print('Yes') else: print('No') # print([ng.sum(i,i+1)for i in range(p+5)],''.join(t))