class segt: def __init__(self, n, ele, calc): self.num = 2 ** (n - 1).bit_length() self.el = ele self.data = [ele] * (2 * self.num) self.calc = calc def update(self, idx, x): idx += self.num - 1 self.data[idx] = x while idx > 0: idx = (idx - 1) // 2 self.data[idx] = self.calc(self.data[2*idx+1], self.data[2*idx+2]) def renew(self, idx, x): self.update(idx, self.calc(self.get(idx), x)) def prod(self, left, right): l = left + self.num r = right + self.num res = self.el while l < r: if l % 2: res = self.calc(res, self.data[l-1]) l += 1 if r % 2: r -= 1 res = self.calc(res, self.data[r-1]) l //= 2 r //= 2 return res def get(self, idx): return self.data[idx+self.num-1] def add(x, y): return x + y def cc(a): b = sorted(a) d = dict() cnt = 0 for v in b: if v not in d: d[v] = cnt cnt += 1 res = [d[v] for v in a] return d n = int(input()) tm = [] ls = [list(map(str, input().split())) for _ in range(n)] d = dict() for i in range(n): s, l, r = ls[i] l, r = int(l), int(r) ls[i][1:] = [l, r] tm.append(l) tm.append(r) if s not in d: d[s] = [] d[s].append(l) d[s].append(r) q = int(input()) qr = [list(map(str, input().split())) for _ in range(q)] nc = set() for i in range(q): qr[i][0] = int(qr[i][0]) if qr[i][0] == 1: qr[i][2] = int(qr[i][2]) tm.append(qr[i][2]) if qr[i][1] not in d: d[qr[i][1]] = [] d[qr[i][1]].append(qr[i][2]) nc.add(qr[i][1]) elif qr[i][0] == 2: qr[i][1] = int(qr[i][1]) tm.append(qr[i][1]) else: qr[i][2] = int(qr[i][2]) qr[i][3] = int(qr[i][3]) tm.append(qr[i][2]) tm.append(qr[i][3]) if qr[i][1] not in d: d[qr[i][1]] = [] d[qr[i][1]].append(qr[i][2]) d[qr[i][1]].append(qr[i][3]) tm = list(set(tm)) idx = cc(tm) st = segt(len(idx)+1, 0, add) idx2 = dict() sd = dict() for s in d.keys(): if s not in nc: continue idx2[s] = cc(list(set(d[s]))) sd[s] = segt(len(idx2[s])+1, 0, add) for s, l, r in ls: st.renew(idx[l], 1) st.renew(idx[r]+1, -1) if s not in nc: continue sd[s].renew(idx2[s][l], 1) sd[s].renew(idx2[s][r]+1, -1) for i in range(q): if qr[i][0] == 1: flg = sd[qr[i][1]].prod(0, idx2[qr[i][1]][qr[i][2]]+1) print("Yes" if flg else "No") elif qr[i][0] == 2: ans = st.prod(0, idx[qr[i][1]]+1) print(ans) else: s, l, r = qr[i][1:] st.renew(idx[l], 1) st.renew(idx[r]+1, -1) if s not in nc: continue sd[s].renew(idx2[s][l], 1) sd[s].renew(idx2[s][r]+1, -1)