from bisect import bisect_left class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): i += 1 s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def sumrange(self, i, j): si = self.sum(i - 1) sj = self.sum(j) return sj - si def add(self, i, x): i += 1 while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, w): if w <= 0: return 0 x = 0 r = 1 << (self.size).bit_length() while r > 0: if x+r < self.size and self.tree[x+r] < w: w -= self.tree[x+r] x += r r = r >> 1 return x N = int(input()) data = {} S = {-1, 2*10**9} T = {} for _ in range(N): s, l, r = input().split() l = int(l) r = int(r)+1 if s in data: data[s].append([l, r]) T[s].add(l) T[s].add(r) else: data[s] = [[l, r]] T[s] = {l, r} S.add(l) S.add(r) Q = int(input()) qq = [list(input().split()) for _ in range(Q)] query = [] for q in qq: if q[0] == '1': t = int(q[2]) query.append([1, q[1], t]) S.add(t) elif q[0] == '2': t = int(q[1]) query.append([2, t]) S.add(t) else: x, l, r = q[1], int(q[2]), int(q[3]) query.append([3, x, l, r]) S.add(l) S.add(r) if x in T: T[x].add(l) T[x].add(r) else: T[x] = {l, r} S = sorted(list(S)) state = Bit(len(S)+1) for k in data: data[k].sort() for l, r in data[k]: state.add(bisect_left(S, l), 1) state.add(bisect_left(S, r), -1) T[k] = sorted(list(T[k])) ans = [] for q in query: if q[0] == 1: x, t = q[1], q[2]+1 if x not in T: ans.append('No') else: ans.append('Yes' if bisect_left(T[x], t) else 'No') elif q[0] == 2: t = q[1] ans.append(state.sum(bisect_left(S, t))) else: l, r = q[2:] indl = bisect_left(S, l) indr = bisect_left(S, r) state.add(indl, 1) state.add(indr, -1) print(*ans, sep='\n')