Territories

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

문제

This time Byteasar researches a wildlife in a nature reserve that has a shape of an X×YX \times Y rectangle. It is divided into XYXY unit squares, there is a square with coordinates (x,y)(x, y) for every 1xX1 \le x \le X and 1yY1 \le y \le Y.

Our hard-working researcher distinguished nn species of animals and discovered that each species dislikes living on some particular rectangle (which is stricly smaller than whole nature reserve). For species number ii it is rectangle described by its two opposite corners (x_i,y_i)(x\_i, y\_i) and (x_i,y_i)(x'\_i, y'\_i), for some x_ix_ix\_i \leq x'\_i and y_iy_iy\_i \leq y'\_i. We know that there are c_ic\_i animals in that species. Therefore, there are S=c_1+c_2++c_nS = c\_1 + c\_2 + \ldots + c\_n animals in total.

Byteasar has an idea for a social-natural experiment which relies on putting each of SS animals in some cell outside of its disliked region. Sociality of a placement is a number of pairs of animals so that both of them are in the same cell. Hence, if a cell contains pp animals, this adds p(p1)2\frac{p(p-1)}{2} to the overall sociality.

It is allowed to put animals from the same species into different cells.

Find the maximum value of the sociality that can be attained.

입력

The first line of input contains three integers nn, XX and YY (1n100,0001 \leq n \leq 100\\,000, 1X,Y10001 \leq X,Y \leq 1000) denoting the number of species and dimensions of nature reserve, respectively.

Each of following nn lines contains a description of species, ii-th of them contains five integers x_i,y_i,x_i,y_i,c_ix\_i, y\_i, x'\_i, y'\_i, c\_i (1x_ix_iX1 \leq x\_i \leq x'\_i \leq X, 1y_iy_iY1 \leq y\_i \leq y'\_i \leq Y, 1c_i10001 \leq c\_i \leq 1000) describing region disliked by species number ii and number of animals in that species. For each ii at least one of the following conditions holds: x_i1x\_i \neq 1, y_i1y\_i \neq 1, x_iXx'\_i \neq X, y_iYy'\_i \neq Y

출력

You need to print one integer -- the maximum possible sociality of some placement.

힌트

In first sample we need to put four animals in a cell (1,1)(1, 1) (contributing 432=6\frac{4 \cdot 3}{2} = 6 to the sociality) and put three remaining animals in a cell (1,2)(1, 2) (contributing 322=3\frac{3 \cdot 2}{2} = 3 to the sociality).

Second sample test is depicted below. All animals can be put in a cell (4,1)(4, 1).