Connecting Cables

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

문제

Recently, RUN was asked to connect cables between all pairs of the NN areas of KAIST.

We treat the areas as regions on the 22-dimensional plane. The boundary of each region is a 44-sided polygon with 22 edges parallel to the xx-axis, and 22 edges parallel to the yy-axis. In other words, each region has a rectangular boundary with (x_1i,y_1i)(x\_1^i,y\_1^i) as a lower left corner and (x_2i,y_2i)(x\_2^i,y\_2^i) as a upper right corner. The regions may overlap.

The cables must be constructed along the xx-axis or the yy-axis, due to safety issues. So the cost of constructing a cable from (x_1,y_1)(x\_1,y\_1) to (x_2,y_2)(x\_2,y\_2) is x_1x_2+y_1y_2\left |x\_1-x\_2\right |+\left |y\_1-y\_2\right | won.

A cable connecting two areas AA and BB should connect two points, one from each region.

Find the minimum sum of the cost for connecting (N2)\binom{N}{2} cables between all pairs of the areas.

Note that the cables must be constructed for all (N2)\binom{N}{2} pairs of areas. This means, for example, even if two endpoints of a cable belong to more than one pair of areas, we do not consider it as connecting all such pairs.

Since the answer can be large, output it modulo 998,244,353998\\, 244\\, 353. It can be proved that the answer is always a non-negative integer.

입력

The first line contains one integer, NN.

The ii-th of the following NN lines contain space-separated four integers x_1ix\_1^i, y_1iy\_1^i, x_2ix\_2^i, and y_2iy\_2^i — indicating the positions of the lower left and the upper right corners of the region representing the ii-th area.

출력

Output a single integer — the minimum cost to construct all cables in the unit of won, modulo 998,244,353998\\, 244\\, 353. 998,244,353=119×223+1998\\, 244\\, 353=119\times 2^{23}+1 is a prime number.

제한

  • 2N300,0002\le N\le 300\\, 000
  • 0x_1i\<x_2i998,244,3520\le x\_1^i\<x\_2^i\le 998\\, 244\\, 352 (1iN1\le i\le N)
  • 0y_1i\<y_2i998,244,3520\le y\_1^i\<y\_2^i\le 998\\, 244\\, 352 (1iN1\le i\le N)