There is a a grid with

rows and

columns, in which there are

monsters.
The

th monster lives in
)
(the

th row of the

th column).
Now we need to build a fortress. The fortress is a rectangular area, with the upper left corner in
)
and the lower right corner in
)
.
All the rows between

and

and the columns between

and

belong to the fortress.
A valid fortress requires
After building the fortress, all monsters

satisfy

or

will be eliminated (i.e. the attack area of the fortress is a cross area)
Now it is required to eliminate all monsters and find the minimum area of the fortress, that is, minimize