Metro 2345

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Kekopolis has three metro lines, they intersect near the city center, forming a triangle of three tunnels between adjacent stations. The first line has xx stations, the second line has yy stations, the third line has zz stations. Stations at each line are numbered consequently starting from 11.

Stations where the lines intersect allow passengers to change between lines. It is possible to change between station aa of the first line and station b+1b+1 of the second line, station a+1a+1 of the first line and station cc of the third line, and station bb of the second line and station c+1c+1 of the third line.

The lines have different speed of trains. The train at the first line travels between adjacent stations in t_1t\_1 seconds, the train at the second line does it in t_2t\_2 seconds, the train at the third line does it in t_3t\_3 seconds. It takes dd seconds to change between lines. Let us ignore the time to enter or leave the station or the train, and the time the train stops at the station.

Dima needs to get to Kekopolis Programming Contest. He starts his way at home that is located near station ii of the kk-th line, and needs to get to Kekopolis University that is located near station jj of the ll-th line. Dima overslept as usually, so he is getting late. Dima wants to get to his destination as soon as possible.

Find the minimum time Dima needs to get from his home the the university. Dima doen't enter nor exists metro at exchange station.

입력

The first line of input contains three integers xx, yy and zz (2x,y,z1092 \le x, y, z \le 10^9). 

The second line contains three integers aa, bb and cc (1a<x1 \le a < x, 1b<y1 \le b < y, 1c<z1 \le c < z). 

The third line contains four integers t_1t\_1, t_2t\_2, t_3t\_3 and dd (1t_1,t_2,t_3,d1091 \le t\_1, t\_2, t\_3, d \le 10^9).

The fourth line contains four integers kk, ii, ll and jj (1k,l31 \le k, l \le 3, it is guaranteed that the kk-th line has station ii, the ll-th line has station jj, the starting station is different from the destination station, in particular they are not the two stations at the same interchange).

출력

Output one integer --- the minimum time needed to travel from the starting station to the destination station.