The segment of numerical axis from 0 to 109
is painted into white color. After that some parts of this segment are
painted into black, then some into white again and so on. In total
there have been made N re-paintings (1 ≤ N ≤ 5000). You are to write a program that finds the longest white open interval after this sequence of re-paintings.
Input
The first line of input contains the only number N. Next N lines contain information about re-paintings. Each of these lines has a form:
ai bi ci
where ai and bi are integers, ci is symbol 'b' or 'w', ai, bi, ci are separated by spaces.
This triple of parameters represents repainting of segment from ai to bi into color ci ('w' 鈥?white, 'b' 鈥?black). You may assume that 0 < ai < bi < 109.
Output
Output should contain two numbers x and y (x < y)
divided by space(s). These numbers should define the longest white open
interval. If there are more than one such an interval output should
contain the one with the smallest x.
Sample
input |
output |
4 1 999999997 b 40 300 w 300 634 w 43 47 b
|
47 634
|
榪欎釜棰樼洰鏈鐩存帴鐨勫姙娉曟槸紱繪暎鍖?紱繪暎鍖栦簡涔嬪悗灝卞ソ鎶樿吘浜?鍥犱負鎿嶄綔鎸囦護寰堝皯,鎵浠ユ垜閫夋嫨紱繪暎+鏈寸礌鏌撹壊.