Fast Postman
A postman has to deliver several letters along a street. He has the address (in the form of the number of meters from the left end of the street to the destination of the letter) and the maximum time he can take to deliver each letter. The postman moves at meter per second and can deliver a letter instantly once he reaches the right location. You need to find out if it's possible to make all the deliveries within the given constraints, and if so, the minimum time the postman can take to do it.
Input
Contains multiple test cases, each of them consists of three lines. In the first line of each test there are two numbers: the number of addresses and the initial position of the postman in the same units and format as the addresses. The second and the third line contains numbers. The -th element of the second and the third line represents the address and maximum time of delivery of the -th letter. Each number in the second line of the test is between and inclusive. Each number in the third line of the test is between and inclusive.
Output
For each test case print in a separate line the minimum amount of time the postman needs to deliver all letters within the given constraints or if it's impossible to do so.