{"raw_statement":[{"iden":"problem statement","content":"You are given $N$ intervals numbered $1$ through $N$, that are as follows:\n\n*   if $t_i=1$, Interval $i$ is $[l_i,r_i]$;\n*   if $t_i=2$, Interval $i$ is $[l_i,r_i)$;\n*   if $t_i=3$, Interval $i$ is $(l_i,r_i]$;\n*   if $t_i=4$, Interval $i$ is $(l_i,r_i)$.\n\nHow many pairs of integers $(i,j)$ satisfying $1 \\leq i \\lt j \\leq N$ are there such that Interval $i$ and Interval $j$ intersect?\nWhat are $[X,Y],[X,Y),(X,Y],(X,Y)$?\n\n*   A closed interval $[X,Y]$ is an interval consisting of all real numbers $x$ such that $X \\leq x \\leq Y$.\n*   A half-open interval $[X,Y)$ is an interval consisting of all real numbers $x$ such that $X \\leq x < Y$.\n*   A half-open interval $(X,Y]$ is an interval consisting of all real numbers $x$ such that $X < x \\leq Y$.\n*   A open interval $(X,Y)$ is an interval consisting of all real numbers $x$ such that $X < x < Y$.\n\nRoughly speaking, square brackets $[]$ mean the endpoint is included, and curly brackets $()$ mean the endpoint is excluded."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 2000$\n*   $1 \\leq t_i \\leq 4$\n*   $1 \\leq l_i \\lt r_i \\leq 10^9$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$t_1$ $l_1$ $r_1$\n$t_2$ $l_2$ $r_2$\n$\\hspace{1cm}\\vdots$\n$t_N$ $l_N$ $r_N$"},{"iden":"sample input 1","content":"3\n1 1 2\n2 2 3\n3 2 4"},{"iden":"sample output 1","content":"2\n\nAs defined in the Problem Statement, Interval $1$ is $[1,2]$, Interval $2$ is $[2,3)$, and Interval $3$ is $(2,4]$.\nThere are two pairs of integers $(i,j)$ such that Interval $i$ and Interval $j$ intersect: $(1,2)$ and $(2,3)$. For the first pair, the intersection is $[2,2]$, and for the second pair, the intersection is $(2,3)$."},{"iden":"sample input 2","content":"19\n4 210068409 221208102\n4 16698200 910945203\n4 76268400 259148323\n4 370943597 566244098\n1 428897569 509621647\n4 250946752 823720939\n1 642505376 868415584\n2 619091266 868230936\n2 306543999 654038915\n4 486033777 715789416\n1 527225177 583184546\n2 885292456 900938599\n3 264004185 486613484\n2 345310564 818091848\n1 152544274 521564293\n4 13819154 555218434\n3 507364086 545932412\n4 797872271 935850549\n2 415488246 685203817"},{"iden":"sample output 2","content":"102"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}