# snippet: templete_ # Last Modified: 2026-02-13 from collections import deque, defaultdict from itertools import permutations, product from bisect import bisect_left, bisect_right from heapq import heappush, heappop from random import randint, shuffle from time import perf_counter as pc def II(): return int(input()) def LI(): return list(map(int,input().split())) def LI_1(): return [int(x) - 1 for x in input().split()] def SI(): return input() def LS(): return list(input().split()) mod = 998244353 inf = 1001001001001001001 import sys sys.setrecursionlimit(10 ** 6) input = lambda: sys.stdin.readline().rstrip() _buf = [] def print(*a, **k): _buf.append(" ".join(map(str, a))) def solve(): Q = II() stack = [] check = [] d = dict() for i in range(Q): q = LS() if q[0] == "1": c = q[1] check.append((c, len(stack))) stack.append(c) else: c = stack.pop() if check and check[-1] == (c, len(stack)): check.pop() else: assert c == ")" assert (c, len(stack)) in d for x in d[c, len(stack)]: check.append(x) while len(check) >= 3: if check[-3][0] == "(" and check[-2][0] == "|" and check[-1][0] == ")": d[check[-1]] = [check[-3], check[-2]] for _ in range(3): check.pop() else: break if len(check) == 0: print("Yes") else: print("No") return if __name__ == "__main__": T = 1 # T = II() for _ in range(T): solve() sys.stdout.write("\n".join(_buf) + "\n")