Distributing Seats

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

문제

An airline called Divided Airlines has recently made the news due to their tendency to overbook their flights rather aggressively. For some flights, they even resorted to dragging passengers out from the plane! This was of course not very popular, so they decided to "resolve" the issue by making the seating assignments very chaotic (airlines do like unnecessary complexity).

A particular flights has nn passengers. The seats are divided into rr rows each containing cc seats. Every passenger ii is assigned to some particular seat located at row a_ia\_i and column b_ib\_i. However, some passengers may be assigned to the same seat.

Of course, passengers are usually okay with sitting somewhere else than their assigned seat, but they may still want to be somewhat close to their original seat. Perhaps they want to be able to speak to their friends, or sit close to their overhead luggage. More specifically, passenger ii accepts sitting at most s_is\_i rows away from the row on their ticket.

Due to budget reasons, you decided to travel on a Divided flight. As expected, all the passengers assigned to an overbooked seat started to fight with each other, moving around in complex ways and causing a long delay. You proposed a fair resolution: you will construct a seat assignment which takes into account how far the passengers accepts to sit from their assigned seats so that as many passengers as possible get a seat. Now, all that remains is to actually find this assignment.

입력

The input consists of:

  • one line with the integers nn, rr and cc (1n,r,c1051 \le n, r, c \le 10^5), the number of passengers, rows and columns in the flight.
  • nn lines with the integers a_i,b_ia\_i, b\_i and s_is\_i (1a_ir1 \le a\_i \le r, 1b_ic1 \le b\_i \le c, 0s_ir0 \le s\_i \le r). The ii'th line has the assigned row a_ia\_i and column b_ib\_i, and maximum distance s_is\_i of the ii'th passenger. The maximum distance is given in rows.

출력

Output the maximum number of passengers that can be assigned a seat in an optimal assignment.