import sys def solve(): input_data = sys.stdin.read().splitlines() if not input_data: return Q = int(input_data[0]) parent = [0] * (Q + 1) char_at = [""] * (Q + 1) depth = [0] * (Q + 1) s_stack_tops = [0] node_count = 0 results = [] for i in range(1, Q + 1): line = input_data[i] if line[0] == '1': c = line[2] prev_top = s_stack_tops[-1] new_top = prev_top matched = False if c == ')' and depth[prev_top] >= 2: mid = prev_top top = parent[mid] if char_at[mid] == '|' and char_at[top] == '(': new_top = parent[top] matched = True if not matched: node_count += 1 char_at[node_count] = c parent[node_count] = prev_top depth[node_count] = depth[prev_top] + 1 new_top = node_count s_stack_tops.append(new_top) else: if len(s_stack_tops) > 1: s_stack_tops.pop() if s_stack_tops[-1] == 0: results.append("Yes") else: results.append("No") sys.stdout.write("\n".join(results) + "\n") if __name__ == "__main__": solve()