{"task": {"agent_timeout": 600, "task": "917", "verifier_timeout": 7200, "instruction": "Please implement a Python 3 solution to the below problem.\nReason through the problem and:\n1. Restate the problem in plain English\n2. Conceptualize a solution first in plain English\n3. Write a pseudocode solution\n4. Save your solution as solution.py\nNo outside libraries are allowed.\n\n[BEGIN PROBLEM]\nThe highway adjacent to Farmer John's farm has recently seen a dramatic increase\nin traffic, or at least so it seems to Farmer John.  To be sure, he wants to\nmeasure the traffic flow on the highway with a set of  sensors, each capable of\nmeasuring the rate of flow of traffic on a  segment of road.  \n\nUnfortunately, while walking through the barn one day, Farmer John trips and\ndrops his box of sensors into a large vat of milk, after which they no longer\nwork as well.  Instead of producing a single exact reading of traffic flow rate,\neach sensor now outputs a range of possible values. For example, a sensor might\noutput the range $[7, 13]$, indicating that the rate of traffic flow on a\nsegment of road is no less than 7, and no greater than 13.\n\nThe highway runs for $N$ miles next to the farm, and traffic on the highway only\nflows in one direction, from mile 1 towards mile $N$.  Farmer John wants to\ninstall $N$ sensors -- one for each 1-mile segment of the highway. In some of\nthese segments, there are on-ramps that allow traffic to enter the highway; in each of\nthese cases, Farmer John will install his sensor on the on-ramp to measure\n(approximately) the amount of incoming traffic.  In some segments there are \noff-ramps that allows traffic to exit the highway; in each of these cases, Farmer John will\ninstall his sensor on the off-ramp.  Each segment contains at most one ramp.  \nIf there is no on-ramp or off-ramp in a segment of highway, Farmer John installs\na sensor on the main highway itself.  \n\nGiven the readings from Farmer John's $N$ sensors, please determine the most\nspecific possible ranges that describe the rate of traffic flow initially on\nthe highway prior to mile 1 and for traffic continuing on the highway past mile\n$N$.  These ranges should be consistent with all $N$ sensor readings.\n\nINPUT FORMAT:\nThe first line of input contains $N$ ($1 \\leq N \\leq 100$).  Each of the\nremaining $N$ lines describes a 1-mile segment of the road, in order from mile\n$1$ to mile $N$.  Each line contains a string that is either \"on\" (if there is\nan on-ramp on this segment), \"off\" (if there is an off-ramp), or \"none\" (if\nthere is no ramp), followed by two integers  in the range $0 \\ldots 1000$,\nindicating the lower and upper endpoints of the sensor range from this segment.\nIf the segment contains a ramp, the sensor reading is from the ramp.  Otherwise,\nit is from the main highway.  At least one of the highway segments will be\ndesignated as \"none\".\n\nOUTPUT FORMAT:\nThe first line of output should contain two integers giving the most specific\nrange possible for the rate of traffic flow prior to mile 1.  The second line of\noutput should contain two integers giving the most specific range possible for\nthe rate of traffic flow after mile $N$.  A valid solution is always guaranteed\nto exist.\n\nSAMPLE INPUT:\n4\non 1 1\nnone 10 14\nnone 11 15\noff 2 3\nSAMPLE OUTPUT: \n10 13\n8 12\n\nIn this example, the combination of readings from segments 2 and 3 tell us that\nthe flow rate through these segments is somewhere in the range $[11, 14]$, since\nonly this range is consistent with both the readings $[10,14]$ and $[11,15]$. In\nmile 1, exactly 1 unit of flow enters on an on-ramp, so prior to mile 1, the\nflow rate must be in the range $[10, 13]$.  In mile 4, between 2 and 3 units\nexits on an off-ramp, so the range of possible flow rates after this is\n$[8,12]$.\n\nProblem credits: Brian Dean\n\n[END PROBLEM]\n", "memory": "2048m", "runnable": false, "difficulty": "medium", "language": "", "cpus": 1, "instruction_truncated": false, "category": "python_programming", "compose": false, "has_solution": true, "oracle": null, "docker_image": "", "taskset": "usaco", "tags": ["python", "programming", "usaco"]}, "runs": []}