Time limit
2s
Memory limit
128 MB
Teddy the panda lives in a forest with N bamboo groves. Each bamboo grove is represented by a point on a plane. The i-th grove has a tastiness value W_i and contains L_i bamboo stalks.
Each day, Teddy chooses one bamboo grove and eats all of its bamboo. From the second day on, he may move only to a grove whose tastiness value is strictly greater than the grove he ate from on the previous day.
The longer Teddy walks, the more bamboo he expects. If the Manhattan distance from the previous grove to the current grove is greater than the current grove's bamboo count L_i, Teddy starts crying. In other words, a move to grove i is allowed only when |x_0 - x_1| + |y_0 - y_1| <= L_i.
You may choose Teddy's starting grove. Find the maximum number of days Teddy can eat bamboo without crying.
The first line contains the number of bamboo groves N.
Each of the next N lines describes one grove with four space-separated integers X_i, Y_i, W_i, and L_i: its coordinates, tastiness value, and bamboo count.
Print the maximum number of days Teddy can eat bamboo without crying.