Fast Bridges

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

문제

Let us consider a square city of size k×kk \times k. There is exactly one house in each cell.

People can go from any cell to neighbouring cell (only by side) in 11 unit of time.

Government decided to build nn fast bridges to make the city better. Each fast bridge connects two cells (x_1,y_1)(x\_1, y\_1) and (x_2,y_2)(x\_2, y\_2) such that x_1x_2x\_1 \neq x\_2 and y_1y_2y\_1 \neq y\_2. People can go from one end of the bridge to another in x_1x_2+y_1y_21|x\_1 - x\_2| + |y\_1 - y\_2| - 1 units of time.

To analyze how the city became faster, you are asked to calculate the sum of shortest distances between all pairs of cells. Since it can be large, find it modulo 998,244,353998\\,244\\,353.

입력

The first line contains two integers nn, kk (0n5000 \leq n \leq 500, 2k1092 \leq k \leq 10^9) --- the number of bridges and the size of the city.

Each of the next nn lines contains four integers x_1x\_1, y_1y\_1, x_2x\_2, y_2y\_2 (1x_1<x_2k1 \leq x\_1 < x\_2 \leq k, 1y_1,y_2k1 \leq y\_1, y\_2 \leq k, y_1y_2y\_1 \neq y\_2). It is guaranteed that all tuples (x_1,y_1,x_2,y_2)(x\_1, y\_1, x\_2, y\_2) are different.

출력

Print a single integer --- the answer to the problem.

힌트

In the first example, the shortest distance between all pairs of cells is 11, so the sum is 66.