Intellectual Implementation

아직 제출이 없습니다시간 제한6초메모리 제한512 MB

문제

There are nn rectangles on the coordinate plane, with sides parallel to the coordinate axis. The ii-th rectangle covers all points (x,y)(x, y) with l_ixr_il\_i \le x \le r\_i and d_iyu_id\_i \le y \le u\_i.

For simplicity, for every iji \neq j, we have l_il_jl\_i \neq l\_j, r_ir_jr\_i \neq r\_j, l_ir_jl\_i \neq r\_j, d_id_jd\_i \neq d\_j, u_iu_ju\_i \neq u\_j, d_iu_jd\_i \neq u\_j.

Count the number of triples (i,j,k)(i, j, k) with 1i<j<kn1 \le i < j < k \le n for which ii-th, jj-th, and kk-th rectangles are pairwise disjoint (every pair of them has no common points).

입력

The first line of the input contains a single integer nn (1n21051 \le n \le 2 \cdot 10^5), the number of rectangles.

The ii-th of the next nn lines contains four integers describing the ii-th rectangle: l_il\_i, r_ir\_i, d_id\_i, u_iu\_i (109l_i<r_i109-10^9 \le l\_i < r\_i \le 10^9,  109d_i<u_i109-10^9 \le d\_i < u\_i \le 10^9).

It is guaranteed that, for every iji \neq j, we have l_il_jl\_i \neq l\_j, r_ir_jr\_i \neq r\_j, l_ir_jl\_i \neq r\_j, d_id_jd\_i \neq d\_j, u_iu_ju\_i \neq u\_j, d_iu_jd\_i \neq u\_j.

출력

Output the number of triples (i,j,k)(i, j, k) with 1i<j<kn1 \le i < j < k \le n for which ii-th, jj-th, and kk-th rectangles are pairwise disjoint.