After going through the receipts from your car trip through Europe this summer, you realised that the gas prices varied between the cities you visited. Maybe you could have saved some money if you were a bit more clever about where you filled your fuel?
To help other tourists (and save money yourself next time), you want to write a program for finding the cheapest way to travel between cities, filling your tank on the way. We assume that all cars use one unit of fuel per unit of distance, and start with an empty gas tank.
The first line contains the number of cities $n$ and the number of roads $m$ ($1 \le n \le 1000$, $0 \le m \le 10000$).
The next line contains $n$ integers $p_i$ ($1 \le p_i \le 100$), where $p_i$ is the fuel price in city $i$. Cities are numbered from $0$ to $n-1$.
Then follow $m$ lines, each with three integers $u$, $v$, and $d$ ($0 \le u, v < n$, $1 \le d \le 100$), telling that there is a road between cities $u$ and $v$ with length $d$.
Then comes a line with the number of queries $q$ ($1 \le q \le 100$), followed by $q$ lines each with three integers $c$, $s$, and $e$ ($1 \le c \le 100$), where $c$ is the fuel-tank capacity of the vehicle, $s$ is the starting city, and $e$ is the goal city.
For each query, output the price of the cheapest trip from city $s$ to city $e$ using a car with the given capacity, or impossible if there is no way of getting from $s$ to $e$ with that car.