query_count = int(input()) parent = [0] state = [-1] top_history = [0] broken_history = [False] for _ in range(query_count): command = input().split() if command[0] == '1': ch = command[1] current_top = top_history[-1] is_broken = broken_history[-1] if is_broken: top_history.append(current_top) broken_history.append(True) elif ch == '(': parent.append(current_top) state.append(0) top_history.append(len(state) - 1) broken_history.append(False) elif ch == '|': if current_top == 0 or state[current_top] == 1: top_history.append(current_top) broken_history.append(True) else: parent.append(parent[current_top]) state.append(1) top_history.append(len(state) - 1) broken_history.append(False) else: if current_top == 0 or state[current_top] == 0: top_history.append(current_top) broken_history.append(True) else: top_history.append(parent[current_top]) broken_history.append(False) else: top_history.pop() broken_history.pop() if not broken_history[-1] and top_history[-1] == 0: print("Yes") else: print("No")