depth=0 S=[("",0)] NG=[] Q=int(input()) for _ in range(Q): q=list(input().split()) if q[0]=="1": if q[1]=="(": depth+=1 S.append((q[1],depth)) elif q[1]=="|": if S[-1][0]=="(": S.append((q[1],depth)) else: S.append((q[1],-1)) NG.append(q[1]) else: if S[-1][0]=="|": S.append((q[1],depth)) depth-=1 else: S.append((q[1],-1)) NG.append(q[1]) else: if S[-1][1]==-1: NG.pop() if S[-1][0]=="(": depth-=1 S.pop() if len(NG)>0: print("No") else: if S[-1]==(")",1) or S[-1]==("",0): print("Yes") else: print("No")