I-Will-Windra has entered a racing contest! The racetrack can be represented as two arrays of integers and , both of length . When I-Will-Windra is at position , they can jump either positions to the left or right, assuming it is within the bounds of the array. Furthermore, this move costs them .
As I-Will-Windra's FIT2004 tutor, you want to help them. Given starting positions and , what is the minimum cost by which I-Will-Windra can get from to . If this is not possible, output -1 instead.
Note that starting positions are 0 indexed.
Input Format
The first line of input will consist of three integers, , and . The next two lines will each consist of integers, representing and respectively.
Output Format
The output should consist of a single integer, the minimum cost or -1 if it is impossible.
Example Input
5 4 2
3 3 1 3 2
533 776 812 489 523
Example Output
523
Example Explanation
This can be completed in one jump, from index 4 to index 2 (of cost 523).
Constraints
Comments