Always the troublemaker, Bessie the cow has stolen Farmer John's tractor and taken off down the road!
The road is exactly miles long, and Bessie drives the entire length of the road before eventually being pulled over by a police officer. The officer gives Bessie a ticket for exceeding the speed limit, for having an expired license, and for operating a motor vehicle while being a cow. While Bessie concedes that the last two tickets are probably valid, she questions whether the officer was correct in issuing the speeding ticket. She wants to determine for herself whether she actually exceeded the speed limit at any point during her journey.
The road is divided into segments. Each segment is described by a positive integer length in miles and an integer speed limit in the range miles per hour. Since the road is miles long, the lengths of all segments add up to . For example, the road might begin with a segment of length miles and a speed limit of miles per hour, followed by a segment of length miles with a speed limit of miles per hour.
Bessie's journey can also be described as a series of segments. During each segment, she travels a certain positive integer number of miles at a constant integer speed. For example, she might begin by traveling miles at a speed of miles per hour, followed by another miles at a speed of miles per hour. The lengths of all segments add up to miles in total. Farmer John's tractor can travel at a maximum speed of miles per hour.
Given this information, determine the maximum amount by which Bessie's speed exceeds the speed limit at any point during her journey.
The first line contains two integers and . The next lines each contain two integers describing a road segment: its length and speed limit.
The next lines each contain two integers describing a segment of Bessie's journey: its length and the speed at which Bessie was driving.
Print one integer — the maximum amount by which Bessie's speed exceeded the speed limit at any point during her journey. If she never exceeds the speed limit, print .
In this example, the road consists of three segments: miles at miles per hour, followed by miles at miles per hour, and then miles at miles per hour. Bessie drives through three segments: miles at miles per hour, miles at miles per hour, and miles at miles per hour. During her first segment, she is only slightly over the speed limit, but her last segment results in the most serious violation, with Bessie exceeding the speed limit by miles per hour for part of the journey. Therefore, the correct answer is .
Example 1