ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1997. Those are not the droids you're looking for

Time limit: 1.0 second
Memory limit: 64 MB
Bar owner: Hey. We don’t serve their kind here.
Luke: What?
Bar owner: Your droids – they’ll have to wait outside. We don’t want them here.
Planet Tatooine is quite far from the center of the Galaxy. It is at the intersection of many hyperspace paths and it hosts smugglers and hoods of all sorts. The pilots who visited external territories have been to the space port bar called Mos Eisley for a drink at least once.
In this bar you can find a bunch of rascals and scoundrels from all over the Galaxy. The bar owner is ready to make drinks for any client except for, perhaps, a droid. Usually the bar has a lot of smugglers hanging out there. Each smuggler spends at least a minutes inside hoping to meet a good client. Cargo owners show up quite often as well. They usually find a dealer quickly, so they never spend more than b minutes in the bar.
The imperial stormtroopers are searching through Tatooine for the escaped droids. The bar owner said that no droids had ever been on his territory. He also said that nobody except for smugglers and cargo owners had been in the place recently.
Help the stormtroopers find out if the owner is a liar. For that, you are going to need the daily records from the sensor on the entrance door. The sensor keeps record of the time when somebody entered the bar or left it. The stormtroopers got the records after the bar had been closed, so there was nobody in the bar before or after the sensor took the records. You can assume that the sensor is working properly. That is, if somebody went through the bar door, the sensor made a record of that. You can also assume that the bar clients go in and out only through the door with the sensor. But the bar owner and the staff use the ‘staff only’ door.

Input

The first line of the input contains integers a and b (1 ≤ a, b ≤ 109, b + 1 < a). The second line contains integer n — the number of records from the sensor (2 ≤ n ≤ 1000). The i-th of the next n lines contains two integers ti and di (1 ≤ ti ≤ 109, di ∈ {0,1}) — the time of the i-th record and direction (0 — in the bar, 1 — out of the bar). The records in the input are listed in the increasing order of ti.

Output

If there is no doubt that somebody who was neither a smuggler nor a cargo owner visited the bar, print "Liar" on a single line. Otherwise, print a line "No reason". And in the following lines list information on all visitors of the bar. The information about a visitor consists of two space-separated numbers — the time this visitor entered the bar and the time he left the bar. If there are multiple solutions that correspond to the sensor records, print any of them.

Samples

inputoutput
6 3
4
1 0
2 0
5 1
10 1
No reason
1 10
2 5
6 3
4
1 0
2 0
6 1
10 1
Liar
Problem Author: Denis Dublennykh (prepared by Oleg Dolgorukov)