Security System
Time limit2.5sMemory limit1024 MB
Choose which laser sensors to activate so that their beams to the walls never meet, maximizing the total importance of the chosen sensors.
Problem
The secret facility of the KOI country can be drawn as a square on the coordinate plane. The lower-left corner of the square is , the upper-right corner is , and its sides are parallel to the axes. Each side of the square is a wall of the facility.

The facility has laser sensors, numbered from to . You are designing a security system that detects intruders with these laser sensors.
Each laser sensor is a point on the coordinate plane. When a sensor is activated, it fires a laser beam from its position in one of four directions: up (the direction), right (the direction), down (the direction), or left (the direction). The beam travels until it reaches a wall, so its path is the segment connecting the sensor and a point on the wall. The directions are numbered 1 to 4: 1 is up, 2 is right, 3 is down, and 4 is left. The figure below shows sensors firing in directions 1, 2, 3, and 4, in that order. Black dots are sensors and red segments are laser beams.

Sensor () is at , and it fires in direction when activated. Different sensors are at different positions. and are integers from to .
You can choose freely which sensors to activate. However, if beams from different sensors meet, the system may misread them, so no two beams may meet, including at their endpoints. The figure below shows beams meeting. Beams may meet at a single point or share a segment.

The importance of sensor () is . Importance is a numeric measure of how much activating that sensor helps security. The security level of the whole system is the sum of the importance values of the activated sensors.
Write a function that returns the maximum possible security level, subject to choosing which sensors to activate so that no two laser beams meet.
Constraints
(for all )
(for all )
(for all )
Each sensor is at a different position.