# https://nagiss.hateblo.jp/entry/2019/07/01/185421 class Bit: def __init__(self, n): self.size = n self.tree = [0]*(n+1) def __iter__(self): psum = 0 for i in range(self.size): csum = self.sum(i+1) yield csum - psum psum = csum raise StopIteration() def __str__(self): # O(nlogn) return str(list(self)) def sum(self, i): # [0, i) の要素の総和を返す if not (0 <= i <= self.size): raise ValueError("error!") s = 0 while i>0: s += self.tree[i] i -= i & -i return s def add(self, i, x): if not (0 <= i < self.size): raise ValueError("error!") i += 1 while i <= self.size: self.tree[i] += x i += i & -i def __getitem__(self, key): if not (0 <= key < self.size): raise IndexError("error!") return self.sum(key+1) - self.sum(key) def __setitem__(self, key, value): # 足し算と引き算にはaddを使うべき if not (0 <= key < self.size): raise IndexError("error!") self.add(key, value - self[key]) import bisect N = int(input()) XLR = [input().split() for _ in range(N)] T = set() X = dict() for x, l, r in XLR: l = int(l) r = int(r) T.add(l) T.add(r) if x not in X: X[x] = [] bisect.insort_left(X[x], l) bisect.insort_left(X[x], r) Q = int(input()) query = [input().split() for _ in range(Q)] for q in query: tp = q[0] if tp=="1": x = q[1] t = int(q[2]) T.add(t) elif tp=="2": t = int(q[1]) T.add(t) else: x = q[1] l = int(q[2]) r = int(q[3]) T.add(l) T.add(r) T = list(T) T.sort() Z = dict() for i, t in enumerate(T): Z[t] = i BIT = Bit(len(T)+1) for x, l, r in XLR: l=int(l) r=int(r) BIT.add(Z[l], 1) BIT.add(Z[r]+1, -1) for q in query: tp = q[0] if tp=="1": x = q[1] t = int(q[2]) if x not in X: print("No") else: pos = bisect.bisect_left(X[x], t) if pos==len(X[x]): print("No") else: if pos%2==0: if X[x][pos]==t: print("Yes") else: print("No") else: print("Yes") elif tp=="2": t = int(q[1]) ans = BIT.sum(Z[t]+1) print(ans) else: x = q[1] l = int(q[2]) r = int(q[3]) BIT.add(Z[l], 1) BIT.add(Z[r]+1, -1) if x not in X: X[x] = [] bisect.insort_left(X[x], l) bisect.insort_left(X[x], r)