Egg Drop Log

From the logged safe and broken drops, compute the lowest floor that could break and the highest floor that could stay safe.

Easy2IntervalsImplementationInterviewNo attempts yetTime limit2sMemory limit256 MB

Problem

You have two eggs and a building with kk floors, and you want to find the highest floor from which an egg can be dropped without breaking. That is the classic riddle.

Someone already ran the experiment and left a log behind. The log lists floor numbers together with the result of dropping an egg from each of those floors. From the log alone, compute two numbers: the lowest floor from which the egg could break, and the highest floor from which the egg might not break.

An egg dropped from floor 11 does not break, and an egg dropped from floor kk always breaks. The log is consistent with itself: if an egg did not break on floor xx, it does not break on any lower floor, and if an egg broke on floor yy, it breaks on every higher floor.

Input

The first line contains two integers nn and kk separated by one space (1n1001 \le n \le 100, 3k1003 \le k \le 100), the number of logged drops and the number of floors of the building. Each of the next nn lines contains a floor number and the result of that drop, separated by one space. The floor number is between 11 and kk, and the result is either SAFE or BROKEN.

Output

Print two integers separated by one space on a single line. The first integer is the lowest floor from which the egg could break while staying consistent with the log. The second integer is the highest floor from which the egg might not break.