문제
The highway adjacent to Farmer John's farm has recently seen a dramatic increase in traffic, or at least so it seems to Farmer John. To be sure, he wants to measure the traffic flow on the highway with a set of sensors, each capable of measuring the rate of flow of traffic on a segment of road.
Unfortunately, while walking through the barn one day, Farmer John trips and drops his box of sensors into a large vat of milk, after which they no longer work as well. Instead of producing a single exact reading of traffic flow rate, each sensor now outputs a range of possible values. For example, a sensor might output the range
The highway runs for
Given the readings from Farmer John's
Problem credits: Brian Dean
입력
The first line of input contains
출력
The first line of output should contain two integers giving the most specific range possible for the rate of traffic flow prior to mile 1. The second line of output should contain two integers giving the most specific range possible for the rate of traffic flow after mile
예제1
4
on 1 1
none 10 14
none 11 15
off 2 3
10 13
8 12
In this example, the combination of readings from segments 2 and 3 tell us that the flow rate through these segments is somewhere in the range