Railways

No attempts yetTime limit3sMemory limit128 MB

Problem

Byteotia State Railways runs a single InterCity line through cc cities, numbered from 11 to cc in the order the train visits them (city 11 is the start and city cc is the end). The train has ss seats, and between any two consecutive stations it may carry at most ss passengers.

Seat reservation requests arrive one at a time and must be answered in the order they arrive. A single request asks for nn seats on the stretch from station oo to station dd, so it occupies nn seats on every section between two consecutive stations from oo up to dd, that is, sections o,o+1,,d1o, o+1, \dots, d-1.

A request is accepted only when every one of those sections still has at least nn free seats at the moment it is processed. Partial fulfilment is not allowed: the train cannot serve only part of the route or fewer passengers than asked. When a request is accepted, the number of occupied seats on each affected section grows by nn; when it is rejected, nothing changes.

Read the description of the line and the list of requests, decide which requests are accepted and which are rejected, and report the answer for every request.

Input

The first line contains three integers cc, ss and rr (1c600001 \le c \le 60000, 1s600001 \le s \le 60000, 1r600001 \le r \le 60000), separated by single spaces: the number of cities on the line, the number of seats in the train, and the number of requests.

Each of the next rr lines describes one request in arrival order. Line i+1i+1 holds the ii-th request as three integers oo, dd and nn (1o<dc1 \le o < d \le c, 1ns1 \le n \le s), separated by single spaces: the origin station, the destination station, and the number of seats requested.

Output

Print rr lines. On line ii print a single character: T if the ii-th request is accepted, or N if it is rejected.