import sys def main(): input = sys.stdin.read().split() idx = 0 N = int(input[idx]) idx += 1 L = None R = None B = None T = None current_area = 0 for _ in range(N): xa = int(input[idx]) ya = int(input[idx+1]) xb = int(input[idx+2]) yb = int(input[idx+3]) idx +=4 l, r = xa, xb b, t = ya, yb new_area = (r - l) * (t - b) if L is None: # First rectangle added = new_area L, R, B, T = l, r, b, t current_area = added else: # Calculate overlap with the current union's bounding box overlap_l = max(L, l) overlap_r = min(R, r) overlap_b = max(B, b) overlap_t = min(T, t) if overlap_l < overlap_r and overlap_b < overlap_t: overlap_area = (overlap_r - overlap_l) * (overlap_t - overlap_b) else: overlap_area = 0 # Check if new rectangle fully contains the current union's bounding box if l <= L and r >= R and b <= B and t >= T: overlap_area = current_area added = new_area - overlap_area # Update the bounding box L = min(L, l) R = max(R, r) B = min(B, b) T = max(T, t) current_area += added print(added) if __name__ == '__main__': main()