p = 0 rem = {} st = [] Q = int(input()) for _ in range(Q): qs = input().split() match qs: case ('1', c): st.append(c) if len(st) >= 3 and st[-3] == '(' and st[-2] == '|' and st[-1] == ')': rem[p] = True st.pop() st.pop() st.pop() else: rem[p] = False p += 1 case ('2',): p -= 1 if rem[p]: st.append('(') st.append('|') else: st.pop() case _: assert False if len(st) == 0: print('Yes') else: print('No')