Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

D. Magic Box

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputOne day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of its vertices is at point (0, 0, 0), and the opposite one is at point (*x*_{1}, *y*_{1}, *z*_{1}). The six faces of the box contain some numbers *a*_{1}, *a*_{2}, ..., *a*_{6}, exactly one number right in the center of each face.

The numbers are located on the box like that:

- number
*a*_{1}is written on the face that lies on the ZOX plane; -
*a*_{2}is written on the face, parallel to the plane from the previous point; -
*a*_{3}is written on the face that lies on the XOY plane; -
*a*_{4}is written on the face, parallel to the plane from the previous point; -
*a*_{5}is written on the face that lies on the YOZ plane; -
*a*_{6}is written on the face, parallel to the plane from the previous point.

At the moment Vasya is looking at the box from point (*x*, *y*, *z*). Find the sum of numbers that Vasya sees. Note that all faces of the box are not transparent and Vasya can't see the numbers through the box. The picture contains transparent faces just to make it easier to perceive. You can consider that if Vasya is looking from point, lying on the plane of some face, than he can not see the number that is written on this face. It is enough to see the center of a face to see the corresponding number for Vasya. Also note that Vasya always reads correctly the *a*_{i} numbers that he sees, independently of their rotation, angle and other factors (that is, for example, if Vasya sees some *a*_{i} = 6, then he can't mistake this number for 9 and so on).

Input

The fist input line contains three space-separated integers *x*, *y* and *z* (|*x*|, |*y*|, |*z*| ≤ 10^{6}) — the coordinates of Vasya's position in space. The second line contains three space-separated integers *x*_{1}, *y*_{1}, *z*_{1} (1 ≤ *x*_{1}, *y*_{1}, *z*_{1} ≤ 10^{6}) — the coordinates of the box's vertex that is opposite to the vertex at point (0, 0, 0). The third line contains six space-separated integers *a*_{1}, *a*_{2}, ..., *a*_{6} (1 ≤ *a*_{i} ≤ 10^{6}) — the numbers that are written on the box faces.

It is guaranteed that point (*x*, *y*, *z*) is located strictly outside the box.

Output

Print a single integer — the sum of all numbers on the box faces that Vasya sees.

Examples

Input

2 2 2

1 1 1

1 2 3 4 5 6

Output

12

Input

0 0 10

3 2 3

1 2 3 4 5 6

Output

4

Note

The first sample corresponds to perspective, depicted on the picture. Vasya sees numbers *a*_{2} (on the top face that is the darkest), *a*_{6} (on the right face that is the lightest) and *a*_{4} (on the left visible face).

In the second sample Vasya can only see number *a*_{4}.

Codeforces (c) Copyright 2010-2017 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Mar/26/2017 12:15:39 (c4).

Desktop version, switch to mobile version.
User lists

Name |
---|