Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

I-Will-Windra has entered a racing contest! The racetrack can be represented as two arrays of integers a and b, both of length n. When I-Will-Windra is at position i, they can jump either a[i] positions to the left or right, assuming it is within the bounds of the array. Furthermore, this move costs them b[i].

As I-Will-Windra's FIT2004 tutor, you want to help them. Given starting positions x and y, what is the minimum cost by which I-Will-Windra can get from x to y. 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, n, x and y. The next two lines will each consist of n integers, representing a and b 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

2 \le n \le 1e5

0 \le x,y \le n-1

1 \le a[i] \le n

1 \le b[i] \le 30


Comments

There are no comments at the moment.