mod = 1000000007 eps = 10**-9 K = 200000 def main(): import sys input = sys.stdin.buffer.readline class Bit: def __init__(self, n): self.size = n self.tree = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.tree[i] i -= i & -i return s def add(self, i, x): while i <= self.size: self.tree[i] += x i += i & -i def lower_bound(self, w): if w <= 0: return 0 x = 0 k = 1 << (self.size.bit_length() - 1) while k: if x + k <= self.size and self.tree[x + k] < w: w -= self.tree[x + k] x += k k >>= 1 return x + 1 N = int(input()) ans_list = [0] * N query = [] for _ in range(N): xn, yn, xp, yp = map(int, input().split()) query.append((-xn, -yn, xp, yp)) for p, q in ((2, 3), (0, 3), (0, 1), (2, 1)): bit_pp = Bit(K+1) bit_pp.add(K+1, 1) y_pp = [0] * (K+2) y_pp[0] = 10**5 for ii in range(N): xp, yp = query[ii][p], query[ii][q] ans = 0 if yp > y_pp[xp]: j = bit_pp.sum(xp) x_nxt = bit_pp.lower_bound(j + 1) if yp > y_pp[x_nxt]: if y_pp[xp] == 0: bit_pp.add(xp, 1) j += 1 y_pp[xp] = yp y_cur = y_pp[x_nxt] x_cur = xp while True: x_prev = bit_pp.lower_bound(j-1) if yp <= y_pp[x_prev]: ans += (x_cur - x_prev) * (yp - y_cur) break else: ans += (x_cur - x_prev) * (yp - y_cur) j -= 1 bit_pp.add(x_prev, -1) y_cur = y_pp[x_prev] y_pp[x_prev] = 0 x_cur = x_prev ans_list[ii] += ans print(*ans_list, sep="\n") if __name__ == '__main__': main()