Forks and knives
In every enchanted forest, there exists a magical café, operated by magical squirrels. As is commonly known, squirrels are quite lazy, so they prefer not to prepare a wide variety of dishes. Consequently, visitors can choose between just two options: a magical salad or another dish. When a visitor arrives at the café, they order one of these two dishes.
Due to deteriorating diplomatic relations with the neighboring forest, this enchanted forest is facing economic challenges, and the café cannot afford to buy new utensils. As a result, the café has only m knives and n forks. To enjoy the salad, a fork is sufficient, whereas the other dish requires both a fork and a knife. Because of this limitation, the squirrels cannot always accommodate all visitors. Specifically, if there aren't enough utensils available when a visitor arrives, the squirrels must apologize, and the visitor will have to go to another café. If there are enough utensils, the visitor eats and returns them after their meal. Your task is to help the squirrels determine whether they can serve each visitor.
Input
The first line of the input file contains three integers n, m, k (1 ≤ n, m, k ≤ 1000) - representing the number of forks, knives, and café visitors, respectively.
The following k lines provide details about the visitors. Each line contains three integers t_i, l_i, and a_i (1 ≤ t_i, l_i ≤ 10000) - indicating the time the i-th visitor arrives, how long they will stay, and what they will order. a_i is 0 if the i-th visitor orders only the magical salad, which requires just a fork, or 1 if they order the other dish, which requires both a fork and a knife.
Visitors are listed in order of increasing arrival time (t_i < t_{i+1} for i = 1...(k-1)). No two visitors arrive simultaneously. If some visitors leave at the same time a new one arrives, the new guest can immediately use their utensils, as the squirrels are very efficient at cleaning.
Output
In the output file, print k lines - one for each visitor. On line i, print Yes if the squirrels can serve the i-th visitor, and No otherwise.