ChatDOJ, Inc. serves a great many models. Users on a paid plan can choose any model ever developed by ChatDOJ, Inc., from the early kuhyaku language model series to dadas-O8, renowned as its latest reasoning model.
To reduce the time spent repeatedly loading the same model onto a server, ChatDOJ, Inc. decided to temporarily keep models on the server after loading them. The memory area used to keep these models is called a cache.
Since large language models are very large and heavy, the production server at ChatDOJ, Inc. can keep at most distinct models in its cache. The cache is initially empty. The production server processes requests one at a time as follows.
HIT. The models in the cache stay the same.MISS. If there is an empty slot, the requested model is inserted into the cache. If the cache is full, the model whose most recent request occurred earliest is removed and replaced with the requested model.In either case, after processing the request, the time of the requested model's most recent request is updated to the time of this request.
ChatDOJ, Inc. processed requests for some models on a separate experimental server. At most distinct models were processed by the experimental server, and all requests for the same model were processed by the same server. Requests processed by the experimental server do not affect the production server's cache.
However, when the request records from the two servers were merged in request order, the information identifying which server had processed each request was lost. Only the requested model number and HIT or MISS remain in the log. The employee who merged the logs will face appropriate disciplinary action.
ChatDOJ, Inc. wants to exclude the experimental server's records and check whether the production server's records are consistent with the cache behavior described above.
Select at most distinct models and remove all requests for those models from the log. Determine whether it is possible to select models so that, when the remaining requests are processed in order starting with an empty cache, every result matches the result recorded in the log. It is allowed to select no models for removal. If all requests are removed, all results are considered to match.
The first line contains the number of logged requests , the number of models the production server's cache can hold , and the maximum number of distinct models that may have been processed by the experimental server , separated by spaces.
The next lines give the log in request order. The -th request consists of a model number and a recorded result , separated by a space.
Print YES if removing at most distinct models makes every remaining request produce its recorded result. Otherwise, print NO.
The output is case-insensitive.
In the first example, replaying the original log removes model from the cache on the third request, so the fourth request produces MISS. Removing every request for model leaves requests for models . Their results are MISS, MISS, and HIT, respectively, which match all the remaining records.
In the second example, if no model is removed, the fourth request disagrees with its record just as in the first example. Removing model makes the remaining records through the fourth request consistent, but model is still in the cache on the final request, so its result is , contrary to the record. If only model or only model is removed, the fifth request produces , again contrary to the record.
HIT or MISS.MISS| 4 | 200 | No additional constraints. |
HITHITIn the third example, the third request produces HIT, so model stays in the cache and its most recent request time is updated. Therefore, model is removed when model is inserted on the next request. All results, including the final request, match the records.