One 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 (x1, y1, z1). The six faces of the box contain some numbers a1, a2, ..., a6, exactly one number right in the center of each face.  The numbers are located on the box like that:   number a1 is written on the face that lies on the ZOX plane;  a2 is written on the face, parallel to the plane from the previous point;  a3 is written on the face that lies on the XOY plane;  a4 is written on the face, parallel to the plane from the previous point;  a5 is written on the face that lies on the YOZ plane;  a6 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 ai numbers that he sees, independently of their rotation, angle and other factors (that is, for example, if Vasya sees some ai = 6, then he can't mistake this number for 9 and so on).

The fist input line contains three space-separated integers x, y and z (|x|, |y|, |z| ≤ 106) — the coordinates of Vasya's position in space. The second line contains three space-separated integers x1, y1, z1 (1 ≤ x1, y1, z1 ≤ 106) — 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 a1, a2, ..., a6 (1 ≤ ai ≤ 106) — the numbers that are written on the box faces.  It is guaranteed that point (x, y, z) is located strictly outside the box.

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

NoteThe first sample corresponds to perspective, depicted on the picture. Vasya sees numbers a2 (on the top face that is the darkest), a6 (on the right face that is the lightest) and a4 (on the left visible face).In the second sample Vasya can only see number a4.

#include <bits/stdc++.h>

using namespace std;

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (long long i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define fillinf(ar, n) fr(i,0,(n)) ar[i] = INF
#define debug(x) cout<<#x<<": "<<x<<endl
#define arr1d(a,n) cout << #a << " : "; fr(_,1,n) cout << a[_] << ' '; cout << endl;
#define arr1d0(a,n) cout << #a << " : "; rep(_,n) cout << a[_] << ' '; cout << endl;
#define arr2d(a,n,m) cout << #a << " :" << endl; fr(_,1,n) {fr(__,1,m) cout << a[_][__] << ' '; cout << endl;}
#define arr2d0(a,n,m) cout << #a << " :" << endl; rep(_,n) {rep(__,m) cout << a[_][__] << ' '; cout << endl;}

#define ull unsigned long long
#define ll long long
#define ld double
#define ui unsigned int
#define all(ar) ar.begin(), ar.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define y0 yyyyyy0
#define y1 yyyyyy1

#define BIT(n) (1<<(n))
#define SQR(x) ((x) * (x))
#define CUBE(x) ((x) * (x) * (x))
#define LSOne(S) (S) & (-S)
inline bool EQ(double a, double b) {return fabs(a - b) < 1e-9;}

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<string> vs;

template<typename T>inline T gcd(T a, T b){if (b == 0)return a;else return gcd(b, a % b);}
template<typename T>inline T lcm(T a, T b){return (a * b) / gcd(a, b);}
template<typename T> string toStr(T x) {stringstream st; st << x; string s; st >> s; return s;}
template<class T>
void splitStr(const string &s, vector<T> &out)
{
    istringstream in(s);
    out.clear();
    copy(istream_iterator<T>(in), istream_iterator<T>(), back_inserter(out));
}

inline int two(int n) {return 1 << n;}
inline int isOnBit(int n, int b) {return (n >> b) & 1;}
inline void onBit(int & n, int b) {n |= two(b);}
inline void offBit(int & n, int b) {n &= ~two(b);}
inline int lastBit(int n) {return n & (-n);}
inline int cntBit(int n) {int res = 0; while(n && ++res) n -= n &(-n); return res;}

const int dx4[] = {-1, 0, 1, 0};
const int dy4[] = {0, 1, 0, -1};
const int dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const int dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};

#define INP "test.inp"
#define OUT "test.out"

#define PI 3.1415926535897932385
#define INF 1000111222
#define EPS 1e-7
#define MAXN 100000
#define MOD 1000000007
#define dec decr
//END OF COMPETITVE PROGRAMMING TEMPLATE
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll modexp(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int main ()
{
	ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            ll x,y,z,x1,y1,z1,a1,a2,a3,a4,a5,a6;
            cin>>x>>y>>z>>x1>>y1>>z1>>a1>>a2>>a3>>a4>>a5>>a6;
            ll ans=0;
            if(z<0)
            {
            	if(x<0)
            	{
            		if(y<0)
            		{
            			ans=a1+a3+a5;
            		}
            		else if(y>y1)
            		{
            			ans=a3+a5+a2;
            		}
            		else
            		{
            			ans=a3+a5;
            		}
            	}
            	else if(x>x1)
            	{
            		if(y<0)
            		{
            			ans=a1+a3+a6;
            		}
            		else if(y>y1)
            		{
            			ans=a6+a3+a2;
            		}
            		else
            		{
            			ans=a3+a6;
            		}
            	}
            	else
            	{
            		if(y<0)
            		{
            			ans=a1+a3;
            		}
            		else if(y>y1)
            		{
            			ans=a2+a3;
            		}
            		else
            		{
            			ans=a3;
            		}
            	}
            }
            else if(z>z1)
            {
            	if(x<0)
            	{
            		if(y<0)
            		{
            			ans=a1+a4+a5;
            		}
            		else if(y>y1)
            		{
            			ans=a4+a5+a2;
            		}
            		else
            		{
            			ans=a4+a5;
            		}
            	}
            	else if(x>x1)
            	{
            		if(y<0)
            		{
            			ans=a1+a4+a6;
            		}
            		else if(y>y1)
            		{
            			ans=a2+a4+a6;
            		}
            		else
            		{
            			ans=a4+a6;
            		}
            	}
            	else
            	{
            		if(y<0)
            		{
            			ans=a1+a4;
            		}
            		else if(y>y1)
            		{
            			ans=a2+a4;
            		}
            		else
            		{
            			ans=a4;
            		}

            	}
            }
            else
            {
            	if(x<0)
            	{
            		if(y<0)
            		{
            			ans=a2+a5;
            		}
            		else if(y>y1)
            		{
            			ans=a5+a1;
            		}
            		else
            		{
            			ans=a5;
            		}
            	}
            	else if(x>x1)
            	{
            		if(y<0)
            		{
            			ans=a1+a6;
            		}
            		else if(y>y1)
            		{
            			ans=a6+a2;
            		}
            		else
            		{
            			ans=a6;
            		}
            	}
            	else
            	{
            		if(y<0)
            		{
            			ans=a1;
            		}
            		else if(y>y1)
            		{
            			ans=a2;
            		}

            	}
            }
            if(x==0&&y<=y1&&y>=0&&z<=z1&&z>=0)
            {
            	ans-=a5;
            }
            else if(x==x1&&y<=y1&&y>=0&&z<=z1&&z>=0)
            {
            	ans-=a6;
            }
            if(y==0&&x<=x1&&x>=0&&z<=z1&&z>=0)
            {
             ans-=a1;
            }
            else if(y==y1&&x<=x1&&x>=0&&z<=z1&&z>=0)
            {
            	ans-=a2;
            }
            if(z==0&&x<=x1&&x>=0&&y<=y1&&y>=0)
            {
            	ans-=a3;
            }
            else if(z==z1&&x<=x1&&x>=0&&y<=y1&&y>=0)
            {
            	ans-=a4;
            }
            cout<<ans<<endl;
            return 0;
}

#include <bits/stdc++.h>

#define sd(x)       scanf("%d", &x)
#define sdn(x)      scanf("%d\n", &x)
#define slld(x)     scanf("%I64d", &x)
#define sc(x)       scanf("%c", &x)
#define pd(x)       printf("%d", x)
#define plld(x)     printf("%I64d\n", x)
#define pc(x)       printf("%c", x)
#define pdln(x)     printf("%d\n", x)
#define prl(x)      cout << x << endl
#define LL          long long
#define forn(i, n)  for(int i = 0; i < (int)n; i++)
#define fori(i, n)  for(int i = 1; i <= (int)n; i++)
#define revn(i, n)  for(int i = (int)(n - 1); i >= 0; i--)
#define pb          push_back
#define pii         pair <int, int>

#define mem(x, y)   memset(x, y, sizeof(x))
#define MAX         100002
#define MOD         1000000007

using namespace std;

int x, y, z, X, Y, Z;
int a[7];

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    sd(x); sd(y); sd(z);
    sd(X); sd(Y); sd(Z);
    fori(i, 6) sd(a[i]);

    int ans = 0;

    if(x >= 0) a[5] = 0;
    if(x <= X) a[6] = 0;
    if(y >= 0) a[1] = 0;
    if(y <= Y) a[2] = 0;
    if(z >= 0) a[3] = 0;
    if(z <= Z) a[4] = 0;

    fori(i, 6) ans += a[i];

    prl(ans);

    return 0;
}

/*
 *
 */
#include<fstream>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<list>
#include<cstring>
#include<stack>
#include<map>
#include<set>
#include<utility>
#include<queue>
#include<deque>
#include<ctime>
#include<complex>
#include<bitset>
#include<time.h>

using namespace std;
#define PB push_back
#define LL long long
#define MP make_pair
typedef unsigned long long ULL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define DBG 0

#define fori(i,a,b) for(int i = (a); i < (b); i++)
#define forie(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i > (b); i--)
#define forde(i,a,b) for(int i = (a); i >= (b); i--)
#define forls(i,a,b,n) for(int i = (a); i != (b); i = n[i])
#define mset(a,v) memset(a, v, sizeof(a))
#define mcpy(a,b) memcpy(a, b, sizeof(a))

#define dout  DBG && cerr << __LINE__ << " >>| "
#define checkv(x) dout << #x"=" << (x) << " | "<<endl
#define checka(array,a,b) if(DBG) { \
dout << #array"[] | " << endl; \
forie(i, a, b) cerr << "[" << i << "]=" << array[i] << " |" << ((i - (a)+1) % 5 ? " " : "\n"); \
if (((b)-(a)+1) % 5) cerr << endl; \
}

#define redata(T, x) T x; cin >> x
#define MIN_LD -2147483648
#define MAX_LD  2147483647
#define MIN_LLD -9223372036854775808
#define MAX_LLD  9223372036854775807
#define MAX_INF 18446744073709551615
const int INF = 0x7fffffff;//use double for addition
inline int  reint() { int d; scanf("%d", &d); return d; }
inline long relong() { long l; scanf("%ld", &l); return l; }
inline char rechar() { scanf(" "); return getchar(); }
inline double redouble() { double d; scanf("%lf", &d); return d; }
inline string restring() { string s; cin >> s; return s; }

typedef set<int> Set;
#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
//set_union(ALL(x1),ALL(x2),INS(x)),set_intersection

int a[10];

struct Point{
	int x,y,z;
	Point(int x,int y,int z):x(x),y(y),z(z){}
};
Point operator - (const Point& A,const Point& B){return Point(A.x-B.x,A.y-B.y,A.z-B.z);}
int dot(const Point& A, const Point& B){
	int res = 0;
	res = A.x*B.x + A.y*B.y + A.z*B.z;
	return res;
}
int main(void){
	int x,y,z,u,v,w;
    cin.sync_with_stdio(false);
    cin >> x >> y >> z >> u >> v >> w;
    x*=2;y*=2;z*=2;u*=2;v*=2;w*=2;
    Point A=Point(x,y,z);
    fori(i,0,6){
    	cin >> a[i];
    }
    vector<Point> p,q;
    p.PB(A-Point(u/2,0,w/2));
    p.PB(A-Point(u/2,v,w/2));
    p.PB(A-Point(u/2,v/2,0));
    p.PB(A-Point(u/2,v/2,w));
    p.PB(A-Point(0,v/2,w/2));
    p.PB(A-Point(u,v/2,w/2));
    q.PB(Point(0,-1,0));
    q.PB(Point(0,1,0));
    q.PB(Point(0,0,-1));
    q.PB(Point(0,0,1));
    q.PB(Point(-1,0,0));
    q.PB(Point(1,0,0));
    int ans = 0;
    fori(i,0,6){
    	if(dot(p[i],q[i])>0){
    		ans += a[i];
    	}
    }

    cout << ans << endl;
    return 0;
}

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<cstring>
#include<ctime>
#include<map>
#include<set>
#include<list>
#include<deque>
#include<iterator>
#include<utility>
#include<climits>
#include<iomanip>

#define LL long long
#define sn(n) scanf("%d",&n) ;
#define slld(n) scanf("%lld",&n) ;
#define sc(n) scanf(" %c",&n) ;
#define ss(n) scanf(" %s",n) ;
#define all(n) n.begin() , n.end()
#define pb push_back
#define vi vector<int>
#define vLL vector<LL >
#define vvi vector<vi >
#define vvLL vector<vLL >
#define vc vector<char>
#define vvc vector<vc >
#define vb vector<bool>
#define vvb vector<vb >
#define pii pair<int , int>
#define fi first
#define se second
#define mp make_pair
#define vpii vector<pii >
#define vvpii vector<vpii >
#define rep(i , a , b) for(int (i) = (a) ; (i) < (b) ; ++(i))
#define rev(i , a , b) for(int (i) = (a)-1 ; (i) >= (b) ; --(i))
#define tr(container , it) for(typeof(container.begin()) it = container.begin() ; it != container.end() ; ++it)
#define mii map<int , int>
#define msi map<string , int>
#define mci map<char , int>
#define INF (1<<31)
#define fast_io ios::sync_with_stdio(0) ; cin.tie(0) ;
#define max_array 100001
#define in() freopen("input.txt" , "r" , stdin) ;
#define out() freopen("output.txt" , "w" , stdout) ;
#define MOD 1000000007
#define max_val 10000000
#define debug() cout << "HI" << endl ;

using namespace std ;

int sum(int a[], int index)
{
    int ans = 0 ;
    rep(i, 1, 7)
        if(i != index)
            ans += a[i] ;
    return ans ;
}

int main()
{
    #ifndef ONLINE_JUDGE
        in() ;
    #endif
    fast_io ;
    int c[3], c1[3] ;
    bool flag[3] = {false} ;
    rep(i, 0, 3)
        cin >> c[i] ;
    rep(i, 0, 3)
        cin >> c1[i] ;
    int a[7] ;
    rep(i, 1, 7)
        cin >> a[i] ;

    int ans = 0 ;

    if(c[0] > c1[0])
        ans += sum(a, 5) ;
    else if(c[0] < 0)
        ans += sum(a, 6) ;
    else
        ans += sum(a, 5) - a[6] ;

    if(c[1] <= c1[1])
        ans -= a[2] ;
    if(c[1] >= 0)
        ans -= a[1] ;
    if(c[2] <= c1[2])
        ans -= a[4] ;
    if(c[2] >= 0)
        ans -= a[3] ;

    cout << ans << endl ;

    return 0 ;
}

#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main ()
{
    long long int x,y,z,x1,y1,z1,a1,a2,a3,a4,a5,a6,s=0;
    cin>>x>>y>>z;
    cin>>x1>>y1>>z1;
    cin>>a1>>a2>>a3>>a4>>a5>>a6;

    if(x>x1)
    s=s+a6;
    else if(x<0)
    s=s+a5;

    if(y>y1)
    s=s+a2;
    else if(y<0)
    s=s+a1;

    if(z>z1)
    s=s+a4;
    else if(z<0)
    s=s+a3;
    cout<<s;
    return 0;
}

#include <iostream>

using namespace std;

int cubePos[ 3 ], curPos[ 3 ];
int a[ 6 ];

int main(){
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );

	for( int i = 0; i < 3; ++i ) cin >> curPos[ i ];
	for( int i = 0; i < 3; ++i ) cin >> cubePos[ i ];
	for( int i = 0; i < 6; ++i ) cin >> a[ i ];

	int ans = 0;

	if( curPos[ 1 ] < 0 ) ans += a[ 0 ];
	else if( curPos[ 1 ] > cubePos[ 1 ] ) ans += a[ 1 ];

	if( curPos[ 2 ] < 0 ) ans += a[ 2 ];
	else if( curPos[ 2 ] > cubePos[ 2 ] ) ans += a[ 3 ];

	if( curPos[ 0 ] < 0 ) ans += a[ 4 ];
	else if( curPos[ 0 ] > cubePos[ 0 ] ) ans += a[ 5 ];

	cout << ans << '\n';

	return 0;
}

#include <cstdio>
using namespace std;
/*中間の勉強したくない＞＜ it is one fifty-seven midnight*/
int a[7],x,y,z,x1,y1,z1,i,j,sum=0;
int main(){
scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&x,&y,&z,&x1,&y1,&z1,&a[1],&a[2],&a[3],&a[4],&a[5],&a[6]);
if(x>x1){sum+=a[6];}
if(x<0){sum+=a[5];}
if(z>z1){sum+=a[4];}
if(z<0){sum+=a[3];}
if(y>y1){sum+=a[2];}
if(y<0){sum+=a[1];}
printf("%d\n",sum);
return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(){
	ll x[2],y[2],z[2];
	cin >> x[0] >> y[0] >> z[0];
	cin >> x[1] >> y[1] >> z[1];
	vector<ll> arr(7);
	for(ll i = 1; i <= 6; ++i)
		cin >> arr[i];
	ll ans = 0;
	if(x[0]<min(x[1],0LL))
		ans+=arr[5];
	if(x[0]>max(x[1],0LL))
		ans+=arr[6];
	if(y[0]<min(y[1],0LL))
		ans+=arr[1];
	if(y[0]>max(y[1],0LL))
		ans+=arr[2];
	if(z[0]<min(z[1],0LL))
		ans+=arr[3];
	if(z[0]>max(z[1],0LL))
		ans+=arr[4];
	cout << ans << '\n';
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<cstdio>
#include<math.h>
#include<cstdlib>
#include<map>
#include<utility>
#include<stack>
#include<fstream>
#include<set>
#include<queue>

using namespace std;
#define ll long long int
vector <ll> v;
vector <ll> v1;
vector <ll> v2;
const ll inf=100000000000005;

#define cincout ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define me(a,i) memset(a,i,sizeof(a))
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define printv(n,v) for(int i=0;i<n;i++)  {cout<<v[i]<<" ";}
#define vin(v,n,a) for(int i=0;i<n;i++)	{v.pb(a);cin>>v[i];}

int main()
	{
	cincout;
	int x,y,z,x1,y1,z1,a1,a2,a3,a4,a5,a6;
	int sum=0;
	cin>>x>>y>>z>>x1>>y1>>z1>>a1>>a2>>a3>>a4>>a5>>a6;
	if(y<0)
		sum+=a1;
	else if(y>y1)
		sum+=a2;
	if(z<0)
		sum+=a3;
  	else if(z>z1)
  		sum+=a4;
  	if(x<0)
  		sum+=a5;
  	else if(x>x1)
  		sum+=a6;
  	cout<<sum<<endl;
  	return 0;
  	}

#include <bits/stdc++.h>
using namespace std;
#define ll long long

struct point
{
    double x,y,z;
    point() {}
    point(double _x,double _y,double _z)
    {
        x = _x;
        y = _y;
        z = _z;
    }
};

struct Vector
{
    double x,y,z;
    Vector() {}
    Vector(point a,point b)
    {
        x = b.x-a.x;
        y = b.y-a.y;
        z = b.z-a.z;
    }
};

double dotProduct(Vector A,Vector B)
{
    return A.x*B.x + A.y*B.y + A.z*B.z;
}

Vector crossProduct(Vector A,Vector B)
{
    Vector res;
    res.x = A.y*B.z - A.z*B.y;
    res.y = A.z*B.x - A.x*B.z;
    res.z = A.x*B.y - A.y*B.x;
    return res;
}

point p[100];
int faces[][4] = {{2,1,1,0},{5,6,6,7},{1,5,5,4},{6,2,2,3},{0,4,4,7},{1,2,2,6}};
Vector sides[10][2];
Vector perp[100],eyes[100];
int fc[100];
int x,y,z,x1,y1,z1;

void process()
{
    p[0].x = 0;
    p[0].y = 0;
    p[0].z = 0;

    p[1].x = x1;
    p[1].y = 0;
    p[1].z = 0;

    p[2].x = x1;
    p[2].y = 0;
    p[2].z = z1;

    p[3].x = 0;
    p[3].y = 0;
    p[3].z = z1;

    p[4].x = 0;
    p[4].y = y1;
    p[4].z = 0;

    p[5].x = x1;
    p[5].y = y1;
    p[5].z = 0;

    p[6].x = x1;
    p[6].y = y1;
    p[6].z = z1;

    p[7].x = 0;
    p[7].y = y1;
    p[7].z = z1;
}

int main()
{
    scanf("%d%d%d%d%d%d",&x,&y,&z,&x1,&y1,&z1);

    for(int i=0; i<6; i++)
        scanf("%d",&fc[i]);

    process();

    for(int i=0; i<6; i++)
    {
        sides[i][0] = Vector(p[faces[i][0]],p[faces[i][1]]);
        sides[i][1] = Vector(p[faces[i][2]],p[faces[i][3]]);
        perp[i] = crossProduct(sides[i][0],sides[i][1]);
    }

    eyes[0] = Vector(p[1],point(x,y,z));
    eyes[1] = Vector(p[6],point(x,y,z));
    eyes[2] = Vector(p[5],point(x,y,z));
    eyes[3] = Vector(p[2],point(x,y,z));
    eyes[4] = Vector(p[4],point(x,y,z));
    eyes[5] = Vector(p[2],point(x,y,z));

    int res = 0;
    for(int i=0; i<6; i++)
    {
        if(dotProduct(eyes[i],perp[i])<0)
            res+=fc[i];
    }

    printf("%d\n",res);

    return 0;
}

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
using namespace std;

#define nln        puts("")                         ///prLLInewline
#define getLLI(a)  scanf("%d",&a);
#define max3(a,b,c) max(a,max(b,c))                  ///3 ta theke max
#define min3(a,b,c) min(a,min(b,c))                  ///3 ta theke min

#define FOR1(i,n)  for(LLI i=1;i<=n;i++)
#define FOR0(i,n)  for(LLI i=0;i<n;i++)                 ///looping
#define FORR(i,n)  for(LLI i=n-1;i>=0;i--)
#define ALL(p)     p.begin(),p.end()

#define SET(p)     memset(p,-1,sizeof(p))
#define CLR(p)     memset(p,0,sizeof(p))            ///memset
#define MEM(p,v)   memset(p,v,sizeof(p))

#define READ(f)    freopen(f, "r", stdin)           /// file
#define WRITE(f)   freopen(f, "w", stdout)

#define SZ(c)      (LLI)c.size()
#define PB(x)      push_back(x)                     ///STL defines
#define MP(x,y)    make_pair(x,y)
#define ff         first
#define ss         second

#define LI         long LLI
#define LLI        long long// LLI
#define f64        long double
#define PI         acos(-1.0)                        ///PI er value

LLI Set(LLI N,LLI pos)
{
    return N=N | (1<<pos);
}
LLI reset(LLI N,LLI pos)
{
    return N= N & ~(1<<pos);
}
bool check(LLI N,LLI pos)
{
    return (bool)(N & (1<<pos));
}
void CI(LLI &_x)
{
    scanf("%I64d",&_x);
}

void CO(LLI &_x)
{
    cout<<_x;
}

template<typename T> void getarray(T a[],LLI n)
{
    for(LLI i=0; i<n; i++) cin>>a[i];
}
template<typename T> void prLLIarray(T a[],LLI n)
{
    for(LLI i=0; i<n-1; i++) cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
}

const double EPS=1e-9;                              ///constatnts
const LLI INF=0x7f7f7f7f;

LLI dr8[8]= {1,-1,0,0,1,-1,-1,1};            ///8 direction move
LLI dc8[8]= {0,0,-1,1,1,1,-1,-1};
LLI dr4[4]= {0,0,1,-1};                      ///4 direction move
LLI dc4[4]= {-1,1,0,0};                      ///or adjacent dir.
LLI kn8r[8]= {1,2,2,1,-1,-2,-2,-1};          ///knight moves
LLI kn8c[8]= {2,1,-1,-2,-2,-1,1,2};
int a[10];
int main() {
    double x, y, z, x1, y1, z1;
cin >> x >> y >> z >> x1 >> y1 >> z1;
        FOR1(i,6) cin >> a[i];
        int res = 0;
        if (x < 0) res += a[5];
        if (x > x1) res += a[6];
        if (y < 0) res += a[1];
        if (y > y1) res += a[2];
        if (z < 0) res += a[3];
        if (z > z1) res += a[4];
        cout << res << endl;

    return 0;

}

#include<bits/stdc++.h>
#include<cmath>
#define ll long long
#define fr first
#define sc second
#define mod 1000000007
#define pii pair<int,int>
#define pdd pair<double,double>
#define mp make_pair
using namespace std;

struct pt{
    double x,y,z;
    void read(){
        cin>>x>>y>>z;
    }
    double dis(pt d){
        return (x - d.x)*(x - d.x) + (y - d.y)*(y - d.y) + (z - d.z)*(z - d.z);
    }
};
int a[6];
pt eyee;
pt s;
pt c[6];

int main(){

    eyee.read();
    s.read();

    for(int i=0 ; i<6 ; i++)cin>>a[i];

    int res =0 ;

    if(eyee.y < 0)res += a[0];
    if(eyee.y > s.y)res += a[1];
    if(eyee.z < 0)res += a[2];
    if(eyee.z > s.z)res += a[3];
    if(eyee.x < 0)res += a[4];
    if(eyee.x > s.x)res += a[5];

    cout<<res;
    return 0;
}

#include <stdio.h>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <map>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <set>
#include <utility>

using namespace std;

typedef long long ll;
typedef long double ld;

ll x, y, z, x2, y2, z2, a[6], sum;

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

	cin >> x >> y >> z;
	cin >> x2 >> y2 >> z2;
	for(int i = 0; i < 6; ++i)
		cin >> a[i];
	if(x > x2)
		sum += a[5];
	if(x < 0)
		sum += a[4];
	if(z > z2)
		sum += a[3];
	if(z < 0)
		sum += a[2];
	if(y > y2)
		sum += a[1];
	if(y < 0)
		sum += a[0];
	cout << sum << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    int x,y,z;cin>>x>>y>>z;
    int X,Y,Z;cin>>X>>Y>>Z;
    vector<int> a(6);
    for(int i=0;i<6;i++) scanf("%d", &a[i]);
    int res = 0;
    if(y < 0) res += a[0];
    if(y > Y) res += a[1];
    if(z < 0) res += a[2];
    if(z > Z) res += a[3];
    if(x < 0) res += a[4];
    if(x > X) res += a[5];
    printf("%d\n", res);
}

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <iomanip>

#include <map>
#include <queue>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main()

{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
int a,b,c;
int d,e,f;
cin>>a>>b>>c;
cin>>d>>e>>f;
int g1,g2,g3,g4,g5,g6;
cin>>g1>>g2>>g3>>g4>>g5>>g6;
int ans = 0;
if(b<0)
    ans+=g1;
if(a<0)
    ans+=g5;
if(c<0)
    ans+=g3;
if(a>d)
    ans+=g6;
if(b>e)
    ans+=g2;
if(c>f)
    ans+=g4;

cout<<ans;
return 0;
}

#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    pair < pair <int,int>, int > vasya,cubic;
    int arr[6],sum=0;
    scanf("%d%d%d",&vasya.first.first,&vasya.first.second,&vasya.second);
    scanf("%d%d%d",&cubic.first.first,&cubic.first.second,&cubic.second);
    for (int i=0; i<6; i++)
        scanf("%d",&arr[i]);
    if(vasya.first.second<0)
        sum+=arr[0];
    if(vasya.first.second>0&&cubic.first.second<vasya.first.second)
        sum+=arr[1];
    if(vasya.second<0)
        sum+=arr[2];
    if(vasya.second>0&&cubic.second<vasya.second)
        sum+=arr[3];
    if(vasya.first.first<0)
        sum+=arr[4];
    if(vasya.first.first>0&&cubic.first.first<vasya.first.first)
        sum+=arr[5];
    printf("%d",sum);
}

#include<bits/stdc++.h>

#define pb push_back
#define len(n) n.length()
#define mp make_pair
#define forp(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n)    for(int i=0;i<n;i++)
#define ren(i,n)    for(int i=n-1;i>=0;i--)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define fre     freopen("0.in","r",stdin),freopen("0.out","w",stdout)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define vll vector<long long int>
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define alll(n,i,j) n.begin()+i,n.begin()+j
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m) memset(n,m,sizeof(n))
#define bitc(n) __builtin_popcount(n)
#define mod 100000000
#define mod2 1000000009
#define ma(m,n) m = max(m,n)
#define mi(m,n) m = min(m,n)
#define EPSILON 1e-6
#define PI 3.14159265358979323846

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif
using namespace std;
typedef unsigned long long int ULL;
typedef long long int LL;
typedef vector<vector<LL> > mat;
#define N 100005
#define INF mod

int x,y,z,a,b,c,A[6];

int main () {
  boost;
  cin >> x >> y >> z >> a >> b >> c;
  rep (i,6) {
      cin >> A[i];
  }
  int sum = 0;
  if (y < 0) sum += A[0];
  if (y > b) sum += A[1];
  if (z < 0) sum += A[2];
  if (z > c) sum += A[3];
  if (x < 0) sum += A[4];
  if (x > a) sum += A[5];
  cout << sum;
  return 0;
}

#include <iostream>
using namespace std;
long long n, m, k, i, j, x, y, z, xx, yy, zz, a[10], res;
main(){
       cin>>x>>y>>z;
       cin>>xx>>yy>>zz;
       for(i=0;i<6;i++){
                        cin>>a[i];
                        }
       if(y<0){
               res+=a[0];
               }
       if(y>yy){
                res+=a[1];
                }
       if(z<0){
               res+=a[2];
               }
       if(z>zz){
                res+=a[3];
                }
       if(x<0){
               res+=a[4];
               }
       if(x>xx){
                res+=a[5];
                }
       cout<<res;
       //system("pause");
       }

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long int
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define F first
#define S second

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<int> adj[200001];
int in[200000 + 1];
map<int, int> mp;
set<int> col[100001];
int power(int x, unsigned int y, int p)
{
  int res = 1;

  x = x % p;
  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  tc = 1;

  while (tc--)
  {
    int x, y, z, x1, y1, z1, a[6],ans=0;
    cin >> x >> y >> z;
    cin >> x1 >> y1 >> z1;
    for (int i = 0; i <6 ;i++){
      cin >> a[i];
    }
    if(x>x1||y>y1||z>z1){
      if (x < 0)
      {
        ans += a[4];
      }
      else if (x >= x1)
      {
        ans += a[5];
      }
      if (y < 0)
      {
        ans += a[0];
      }
      else if (y > y1)
      {
        ans += a[1];
      }
      if (z < 0)
      {
        ans += a[2];
      }
      else if (z > z1)
      {
        ans += a[3];
      }
    }
    else{
    if(x<=0){
      ans += a[4];
    }
    else if(x>=x1){
      ans += a[5];
    }
    if (y <= 0)
    {
      ans += a[0];
    }
    else if (y >= y1)
    {
      ans += a[1];
    }
    if (z <= 0)
    {
      ans += a[2];
    }
    else if (z >= z1)
    {
      ans += a[3];
    }
    }
    cout << ans << endl;
  }
  return 0;
}

#include <iostream>
#include <fstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<ctime>
#include<memory.h>
#include<algorithm>
#define sqr(x) ((x)*(x))
#define sqrt(x) sqrt((x)*1.)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(x) ((x)>0?(x):-(x))
#define getar(m,n) for(int _=0;_<n;++_) cin>>(m)[_];
//#define flush {cout.flush();fflush(stdout);}
#define FOR(i,a,b) for(int i=(a),_b(b);i<_b;++i)
#define FORD(i,a,b) for(int i=(a),_b(b);i>=_b;--i)
#define REP(i,n) FOR(i,0,n)
#define CL(x) memset(x, 0, sizeof(x))
#define SINF(x) memset(x, 0x3F, sizeof(x));
#define SVAL(x, y) memset(x, y, sizeof(x))
#define CP(t, f) memcpy(t, f, sizeof(f));
#define CPS(t, f, s) memcpy(t, f, s*sizeof(f[0]));
#define random(x) (((rand()<<15)+rand())%(x))
#define pi 3.1415926535897932
#define y1 stupid_cmath
#define y0 qstupid_cmath_make_me_cry
#define tm stupid_ctime
#define pb push_back
#define mp make_pair
//#define long long long
#include<map>
#include<set>
#include<queue>
//const unsigned long long mod=(long long)1000000*1000000+7;
#define mod 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<cassert>
using namespace std;

typedef long long lli;
typedef long double ld;
typedef unsigned long long ulli;
typedef unsigned int ui;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
const int INF=1;
ll *pref=new ll[100001];
ll sum(int a,int b)
{
    if (a==0)
        return pref[b];
    else
        return pref[b]-pref[a-1];
}
int main()
{
    int x,y,z;
    int x1,y1,z1;
    cin>>x>>y>>z;
    cin>>x1>>y1>>z1;
    int a[6];
    for (int i=0;i<6;i++)
    cin>>a[i];
    int sum=0;
    if (x<0) sum+=a[4];
    if (x>x1)
        sum+=a[5];
    if (y<0)
        sum+=a[0];
    if (y>y1)
        sum+=a[1];
    if (z<0)
        sum+=a[2];
    if (z>z1)
        sum+=a[3];
    cout<<sum<<endl;
    return 0;
}

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mp make_pair
#define REPP(i,l,r,c) for (int i=l;i<r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define REPS(i,l,r) REP(i,l,r+1)
#define FOR(i,n) REP(i,0,n)
#define REPD(i,l,r) for (int i=r-1;i>=l;i--)
#define FORD(i,n) REPD(i,0,n)
#define FOREACH(i,n) for (auto i:n)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

const int INF=(int)1E9;
const ll INFLL=(ll)1E15;
const ll MOD=(ll)1E9+7;
const double PI=acos(-1);
const double EPS=1E-9;

bool between(int x,int l,int r) {
	return (l<=x && x<=r);
}

string tostring(int x) {
	char dum[20]; sprintf(dum,"%d",x);
	string ret(dum); return ret;
}

void in(int &number) {
    bool negative=false; register int c; number=0;
    c=getchar();
    if (c=='-') negative=true, c=getchar();
    for (;c>47&&c<58;c=getchar()) number=number*10+c-48;
    if (negative) number*=-1;
}

int x,y,z,x1,y1,z1,a1,a2,a3,a4,a5,a6;

int main() {
	cin>>x>>y>>z>>x1>>y1>>z1>>a1>>a2>>a3>>a4>>a5>>a6;
	int ans=0;
	if (y<0) ans+=a1;
	if (y>y1) ans+=a2;
	if (z<0) ans+=a3;
	if (z>z1) ans+=a4;
	if (x<0) ans+=a5;
	if (x>x1) ans+=a6;
	cout<<ans<<endl;
	return 0;
}

#pragma comment(linker, "/STACK:1024000000,1024000000")
//c++提交 栈空间扩充
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <sstream>
#include <cstddef>
#include <algorithm>
#include <utility>
#include <iterator>
#include <numeric>
#include <list>
#include <complex>
#include <cstdio>
#include <climits>
#include <iostream>
#include <fstream>

/*** TEMPLATE CODE STARTS HERE ***/

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef __int64 ll;
typedef complex<double> pnt;
typedef pair<int, int> pii;

#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define ls rt << 1
#define rs rt << 1 | 1

#define inf (1<<30-1)
#define eps 1e-6
#define N 105
/*** TEMPLATE CODE ENDS HERE */
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

struct Point{
	double x,y,z;
	void read(){
		cin>>x>>y>>z;
	}
	Point(){}
	Point(double xx,double yy,double zz):x(xx),y(yy),z(zz){}
	double operator*(Point p){
		return x*p.x+y*p.y+z*p.z;
	}
}a[6],jian[6];
int lx[6];
int main(){
	a[0] = Point(0,-1,0);jian[0]=Point(0,0,0);
	a[1] = Point(0,1,0);
	a[2] = Point(0,0,-1);jian[2]=Point(0,0,0);
	a[3] = Point(0,0,1);
	a[4] = Point(-1,0,0);jian[4]=Point(0,0,0);
	a[5] = Point(1,0,0);
	Point v,b;
	v.read();
	b.read();
	for(int i=0;i<6;i++)cin>>lx[i];
        jian[1]=Point(0,b.y,0);
        jian[3]=Point(0,0,b.z);
        jian[5]=Point(b.x,0,0);
	int sum=0;
	for(int i=0;i<6;i++){
		if(a[i]*Point(v.x-jian[i].x,v.y-jian[i].y,v.z-jian[i].z)>eps){
			sum +=lx[i];
		}
	}
	cout<<sum<<endl;
	return 0;
}

#include<iostream>
using namespace std;
int main()
{
	long long x,y,z;
	cin >> x >> y >> z;
	long long a,b,c;
	cin >> a >> b >> c;
	long long a1,a2,a3,a4,a5,a6;
	cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6;
	if(x > a)
	{
		if(y > b)
		{
			if(z > c)
			{
				cout << a2 + a4 + a6<< endl;;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a2 + a6<< endl;
			}
			else
			{
				cout << a2 + a3 + a6 << endl;
			}
		}
		else if(y >= 0 && y <= b)
		{
			if(z > c)
			{
				cout <<  a4 + a6;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a6 << endl;
			}
			else
			{
				cout << a6 + a3 << endl;
			}
		}
		else
		{
			if(z > c)
			{
				cout << a4 + a6 + a1 << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a6 + a1 << endl;
			}
			else
			{
				cout << a6 + a1 + a3 << endl;
			}
		}
	}
	else if(x >= 0 && x <= a)
	{
		if(y > b)
		{
			if(z > c)
			{
				cout << a4 + a2 << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a2 << endl;
			}
			else
			{
				cout << a2 + a1 << endl;
			}
		}
		else if(y >= 0 && y <= b)
		{
			if(z > c)
			{
				cout << a4 << endl;
			}
			else if(z < c)
			{
				cout << a4 << endl;
			}
		}
		else
		{
			if(z > c)
			{
				cout << a4 + a1 << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a1 << endl;
			}
			else
			{
				cout << a1 + a3 << endl;
			}
		}
	}
	else
	{
		if(y > b)
		{
			if(z > c)
			{
				cout << a5 + a4 + a2 << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a5 + a2 << endl;
			}
			else
			{
				cout << a5 + a2 + a3 << endl;
			}
		}
		else if(y >= 0 && y <= b)
		{
			if(z > c)
			{
				cout << a5 + a4 <<endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a5 << endl;
			}
			else
			{
				cout << a5 + a1 << endl;
			}
		}
		else
		{
			if(z > c)
			{
				cout << a5 + a1 + a4  << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a5 + a1 << endl;
			}
			else
			{
				cout << a5 + a1 + a3 << endl;
			}
		}
	}
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef cc_hash_table<int, int, hash<int > > ht;

#define int long long
#define  st first
#define  nd second

const int M = 1e8;
const int  maxn = 1e5+5;
const int  inf =  1e16;

int32_t main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int x , y , z ;
  int x1 , y1 , z1 ;
  cin >> x >> y >> z ;
  cin >> x1 >> y1 >> z1;
  int a1,a2,a3,a4,a5,a6;
  cin >> a1>>a2>>a3>>a4>>a5>>a6;
  int ans = 0 ;

  if(y>y1){
    ans += a2 ;
  }
  else if(y<0){
    ans+= a1 ;
  }
  if(z > z1){
    ans+=a4;
  }
  else if(z<0){
    ans+=a3;
  }
  if(x> x1){
    ans+=a6;
  }
  else if(x<0)
  {
    ans+=a5;
  }
  cout << ans ;

}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back

int a[7];
int main()
{
	//freopen("inputf.txt","r",stdin);
	int aa,b,c,x,y,z;
	scanf("%d %d %d %d %d %d",&x,&y,&z,&aa,&b,&c);
	for(int i=1;i<=6;i++)
		scanf("%d",&a[i]);
	int ans = 0;
	if(x>aa)
		ans+=a[6];
	if(x<0)
		ans+=a[5];
	if(y>b)
		ans+=a[2];
	if(y<0)
		ans+=a[1];
	if(z>c)
		ans+=a[4];
	if(z<0)
		ans+=a[3];
	cout<<ans;
	return 0;
}

/*
ID:   cs_diab1
TASK:
LANG: C++
*/

#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <limits>
#include <string>
#include <vector>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

#define stop exit(0)
#define nc -1
#define eps 1e-10
#define inf 1000000000
#define mp make_pair

#define fill(array,value) memset(array,value,sizeof(array))
#define f(i,beg,end) for(int i=beg; i<=end; i++)
#define F(i,beg,end) for(int i=beg; i>=end; i--)
#define Max(a,b) ( (a>b)?a:b )
#define Min(a,b) ( (a<b)?a:b )
#define pi 3.1415926535897932384626433832
#define iread(var) scanf("%d",&var)
#define dread(var) scanf("%f",&var)
#define lread(var) scanf("%lld",&var)
#define input(name) freopen(name,"r",stdin)
#define output(name) freopen(name,"w",stdout)
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef long long ll;

using namespace std;

int xx, yy, zz, x2, y2, z2, a[7];

void init()
{
    cin>>xx>>yy>>zz;
    cin>>x2>>y2>>z2;

    f(i,1,6) cin>>a[i];

    int sum=0;
    if (yy>y2) sum+=a[2];
    if (yy<0) sum+=a[1];
    if (zz>z2) sum+=a[4];
    if (zz<0) sum+=a[3];
    if (xx>x2) sum+=a[6];
    if (xx<0) sum+=a[5];

    cout<<sum<<endl;
}

int main()
{
    //redirect();
    //input("test.txt");
    init();

    return 0;
}

#include <iostream>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int x, y, z, x1, y11, z1;
int a[6];

int main() {
    cin >> x >> y >> z >> x1 >> y11 >> z1;
    for (int i = 0; i < 6; i++) {
        cin >> a[i];
    }
    int ans = 0;
    if (y < 0) {
        ans += a[0];
    }
    if (y > y11) {
        ans += a[1];
    }
    if (z < 0) {
        ans += a[2];
    }
    if (z > z1) {
        ans += a[3];
    }
    if (x < 0) {
        ans += a[4];
    }
    if (x > x1) {
        ans += a[5];
    }
    cout << ans << endl;
    return 0;
}

#include <conio.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <vector>
#include <string>

using namespace std;

int main()
{
	long long x,y,z;
	cin>>x>>y>>z;
	long long x_,y_,z_;
	cin>>x_>>y_>>z_;
	vector <long long> a(6);
	int count=0;
	int i,j,k;
	for(i=0;i<6;++i)
		cin>>a[i];
	if(x<0){
		count+=a[4];
		if(y<0)
			count+=a[0];
		else if( y>y_)
			count+=a[1];
		if(z<0)
			count+=a[2];
		else if(z>z_)
			count+=a[3];
	}
	else if(x>x_){
		count+=a[5];
		if(y<0)
			count+=a[0];
		else if( y>y_)
			count+=a[1];
		if(z<0)
			count+=a[2];
		else if(z>z_)
			count+=a[3];
	}
	else if(x>=0 && x<=x_){
		if(y<0)
			count+=a[0];
		else if( y>y_)
			count+=a[1];
		if(z<0)
			count+=a[2];
		else if(z>z_)
			count+=a[3];
	}
	cout<<count;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(i) push_back(i)
#define ff first
#define ss second
ll t,n,a,b,c,d,k,y,q,M=1e9+7;
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

// Function to calculate all common divisors
// of two given numbers
// a, b --> input integer numbers
int commDiv(int a, int b)
{
    // find gcd of a, b
    int n = gcd(a, b);

    // Count divisors of n.
    int result = 0;
    for (int i = 1; i <= sqrt(n); i++) {
        // if 'i' is factor of n
        if (n % i == 0) {
            // check if divisors are equal
            if (n / i == i)
                result += 1;
            else
                result += 2;
        }
    }
    return result;
}

bool match(string &text,string &pattern,int n)
{
    if(text.size()%n!=0 || pattern.size()%n!=0)return false;
    if(pattern.size()==0)return false;
    for(int i=0;i<text.size();i++)
    {
        if(text[i]!=pattern[i%n])
            return false;
    }
    return true;
}
int main()
{
    ll fz,fx,fy,x,y,z;
    cin>>x>>y>>z;
    cin>>fx>>fy>>fz;
    ll A[6];
    for(int i=0;i<6;i++)cin>>A[i];
    ll ans=0;
    if(y<0)ans+=A[0];
    if(y>fy)ans+=A[1];
    if(z<0)ans+=A[2];
    if(z>fz)ans+=A[3];
    if(x<0)ans+=A[4];
    if(x>fx)ans+=A[5];
    cout<<ans<<endl;
}

#include <map>
#include <vector>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <algorithm>

#define int ll
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(v)  (v).begin(), (v).end()
#define rall(v)  (v).rbegin(), (v).rend()
#define pb push_back
#define eb emplace_back
#define mp make_tuple
#define fst(x) (get<0>(x))
#define snd(x) (get<1>(x))

#ifndef ONLINE_JUDGE
#define _tr(x) #x<<" = "<<(x)
#define trace(x) {cerr<<_tr(x)<<endl;}
#define trace2(x,y) {cerr<<_tr(x)<<" "<<_tr(y)<<endl;}
#define trace3(x,y,z) {cerr<<_tr(x)<<" "<<_tr(y)<<" "<<_tr(z)<<endl;}
#else
#define trace(x) {}
#define trace2(x,y) {}
#define trace3(x,y,z) {}
#endif

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef tuple<int,int> int2;

template<class T> ostream& operator<<(ostream& os, vector<T> v){ for(T x : v) os << x << " "; return os; }
template<class T> istream& operator>>(istream& is, vector<T>& v){ for(T& x : v) is >> x; return is; }

const int INF = 1LL << 60;

void run() {

  /* entry point */
  int x, y, z;
  int x1, y1, z1;
  vi a(6);

  cin >> x >> y >> z;
  cin >> x1 >> y1 >> z1;
  cin >> a;

  int ans = 0;
  if(y < 0) ans += a[0];
  if(y > y1) ans += a[1];
  if(z < 0) ans += a[2];
  if(z > z1) ans += a[3];
  if(x < 0) ans += a[4];
  if(x > x1) ans += a[5];

  cout << ans << endl;

}

#undef int
int main() { run(); return 0; }

#include<bits/stdc++.h>
using namespace std;
int x,y,z,x1,y1,z1,a[7],ans;
int main(){
	cin>>x>>y>>z;
	cin>>x1>>y1>>z1;
	for(int i=1;i<=6;i++)
		cin>>a[i];
	if(y<0)
		ans+=a[1];
	if(y>y1)
		ans+=a[2];
	if(z<0)
		ans+=a[3];
	if(z>z1)
		ans+=a[4];
	if(x<0)
		ans+=a[5];
	if(x>x1)
		ans+=a[6];
	cout<<ans<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define fr(i,t) for(i=0;i<t;i++)
#define fr1(i,r,t) for(i=r;i<t;i++)
typedef long long int lli;
typedef unsigned long long int ulli;
#define ff first
#define ss second
double pie=3.14159265358979323846;
#define dbug(x) cout<<#x<<"="<<x<<endl;
#define dbug2(x,y)
lli M=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	lli T,n,i,j,k=0,m,j1,co=0,check,mi,l,sum;
	lli ans=0;
    // cin>>T;
    // fr(i,T)
    // {
        lli a[6],x[3],y[3];
        fr(j,3) cin>>x[j];
        fr(j,3) cin>>y[j];
        fr(j,6) cin>>a[j];
        ans=0;
        if(x[0]>y[0]&&x[0]>0)
        {
            ans+=a[5];
        }
        else if(x[0]<y[0]&&x[0]<0)
        {
            ans+=a[4];
        }
        if(x[1]>y[1]&&x[1]>0)
        {
            ans+=a[1];
        }
        else if(x[1]<y[1]&&x[1]<0)
        {
            ans+=a[0];
        }
        if(x[2]>y[2]&&x[2]>0)
        {
            ans+=a[3];
        }
        else if(x[2]<y[2]&&x[2]<0)
        {
            ans+=a[2];
        }
        cout<<ans<<endl;
    // }

}

#include <bits/stdc++.h>
using namespace std;

int main(){
    int x,y,z,x1,y1,z1,a1,a2,a3,a4,a5,a6,ans=0;
    cin>>x>>y>>z>>x1>>y1>>z1>>a1>>a2>>a3>>a4>>a5>>a6;
    if(x>x1)ans+=a6;
    else if(x<0)ans+=a5;
    if(y>y1)ans+=a2;
    else if(y<0)ans+=a1;
    if(z>z1)ans+=a4;
    else if(z<0)ans+=a3;
    cout<<ans;
    return 0;
}

//{
#include<bits/stdc++.h>
#define fr(i,n) for(register int i=0;i<n;i++)
#define fi(i,k,n) for(register int i=k;i<=n;i++)
#define ll long long
#define pp pair<int,int>
#define pi acos(-1.)
#define mod  1000000007
using namespace std;
//}
int main()
{//freopen("a.txt","r",stdin);

int x,x1,y,y1,z,z1,a[6],an=0;
scanf("%d%d%d%d%d%d",&x,&y,&z,&x1,&y1,&z1);

fr(i,6)scanf("%d",&a[i]);
if(x<0)an+=a[4];
else if(x>x1)an+=a[5];
if(y<0)an+=a[0];
else if(y>y1)an+=a[1];
if(z<0)an+=a[2];
else if(z>z1)an+=a[3];
printf("%d\n",an);

}

/*
Author- Aasav Badera
Time- Mon Aug 31 20:34:26 2020
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define endl               '\n'
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const long long int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;

int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
		int x, y, z, x1, y1, z1;
		cin >> x >> y >> z >> x1 >> y1 >> z1;
		int a[6];
		rep(i ,0, 6)cin >> a[i];
		if(x < 0)
		{
			if(y < 0)
			{
				if(z < 0)
				{
					cout << a[0] + a[2] + a[4] << endl;
				}
				else
				{
					if(z >= 0 and z <= z1)
					{
						cout << a[0] + a[4] << endl;
					}
					else
					{
						cout << a[0] + a[3] + a[4] << endl;
					}
				}
			}
			else
			{
				if(y >= 0 and y <= y1)
				{
					if(z < 0)
					{
						cout << a[2] + a[4] << endl;
					}
					else
					{
						if(z <= z1)
						{
							cout << a[4] << endl;
						}
						else
						{
							cout << a[3] + a[4] << endl;
						}
					}
				}
				else
				{
					if(z < 0)
					{
						cout << a[2] + a[4] + a[1] << endl;
					}
					else
					{
						if(z <= z1)
						{
							cout << a[1] + a[4] << endl;
						}
						else
						{
							cout << a[3] + a[1] + a[4] << endl;
						}
					}
				}
			}
		}
		else
		{
			if(x >= 0 and x <= x1)
			{
				if(y < 0)
				{
					if(z < 0)
					{
						cout << a[0] + a[2] << endl;
					}
					else
					{
						if(z <= z1)
						{
							cout << a[0] << endl;
						}
						else
						{
							cout << a[3] + a[0] << endl;
						}
					}
				}
				else
				{
					if(y <= y1)
					{
						if(z < 0)
						{
							cout << a[2] << endl;
						}
						else
						{
							if(z <= z1)
							{
								;
							}
							else
							{
								cout << a[3] << endl;
							}
						}
					}
					else
					{
						if(z < 0)
						{
							cout << a[1] + a[2] << endl;
						}
						else
						{
							if(z <= z1)
							{
								cout << a[1] << endl;
							}
							else
							{
								cout << a[1] + a[3] << endl;
							}
						}
					}
				}
			}
			else
			{
				if(y < 0)
				{
					if(z < 0)
					{
						cout << a[0] + a[2] + a[5] << endl;
					}
					else
					{
						if(z <= z1)
						{
							cout << a[0] + a[5] << endl;
						}
						else
						{
							cout << a[0] + a[5] + a[3] << endl;
						}
					}
				}
				else
				{
					if(y <= y1)
					{
						if(z < 0)
						{
							cout << a[2] + a[5] << endl;
						}
						else
						{
							if(z <= z1)
							{
								cout << a[5] << endl;
							}
							else
							{
								cout << a[3] + a[5] << endl;
							}
						}
					}
					else
					{
						if(z < 0)
						{
							cout << a[2] + a[1] + a[5] << endl;
						}
						else
						{
							if(z <= z1)
							{
								cout << a[1] + a[5] << endl;
							}
							else
							{
								cout << a[1] + a[3] + a[5] << endl;
							}
						}
					}
				}
			}
		}
    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <string>

using namespace std;

#define pb push_back
#define mp make_pair
#define rs resize
#define sz size
#define inf 1e9

typedef long long ll;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <bool> vb;
typedef vector <vb> vvb;
typedef pair <int, int> pii;
typedef vector <ll> vl;
typedef vector <string> vs;

int main()
{
    int x, y, z, x1, y1, z1;
    cin >> x >> y >> z >> x1 >> y1 >> z1;
    int a[6];
    for(int i = 0; i < 6; ++i)
        cin >> a[i];
    int s = 0;
    if (y < 0)
        s += a[0];
    if (y > y1)
        s += a[1];
    if (z < 0)
        s += a[2];
    if (z > z1)
        s += a[3];
    if (x < 0)
        s += a[4];
    if (x > x1)
        s += a[5];
    cout << s;
}

#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
using namespace std;

int main() {
	LL a,b,c,x,y,z,ar[10],ans=0;
	cin>>a>>b>>c;
	cin>>x>>y>>z;
	for(int i=1;i<=6;i++) cin>>ar[i];
	if(a<0) ans += ar[5];
	else if(a>x) ans += ar[6];
	if(b<0) ans += ar[1];
	else if(b>y) ans += ar[2];
	if(c<0) ans += ar[3];
	else if(c>z) ans += ar[4];
	cout<<ans<<endl;
	return 0;
}

#include <iostream>

using namespace std;
int arr[6];
int main()
{
    int a , b ,c , x , y , z;
    cin>>x>>y>>z>>a>>b>>c;
    for(int i = 0  ; i<6 ; i++) cin>>arr[i];
    int ans = 0;
    if(x > a) ans+=arr[5];
    else if(x < 0) ans+=arr[4];

    if(y > b) ans+=arr[1];
    else if(y < 0) ans+=arr[0];

    if(z > c) ans+=arr[3];
    else if(z < 0) ans+=arr[2];

    cout<<ans<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define pb push_back

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x1,y1,z1,x2,y2,z2;
    int a[6];
    cin>>x1>>y1>>z1>>x2>>y2>>z2;
    for (int i=0;i<6;i++)
        cin>>a[i];
    int sum=0;
    if (y1<0)
        sum+=a[0];
    else if (y1>y2)
        sum+=a[1];
    if (z1<0)
        sum+=a[2];
    else if (z1>z2)
        sum+=a[3];
    if (x1<0)
        sum+=a[4];
    else if (x1>x2)
        sum+=a[5];
    cout<<sum;

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    int obs[3], box[3], a[6];
    for (int i = 0; i < 3; i++) {
        cin >> obs[i];
    }
    for (int i = 0; i < 3; i++) {
        cin >> box[i];
    }
    for (int i = 0; i < 6; i++) {
        cin >> a[i];
    }
    pair<char, int> plane[6] = {{'y', 0},
                                {'y', box[1]},
                                {'z', 0},
                                {'z', box[2]},
                                {'x', 0},
                                {'x', box[0]}};
    int sum = 0;
    for (int i = 0; i < 6; i++) {
        int val1, val2;
        if (plane[i].first == 'x') {
            val1 = plane[i].second;
            val2 = obs[0];
        } else if (plane[i].first == 'y') {
            val1 = plane[i].second;
            val2 = obs[1];
        } else if (plane[i].first == 'z') {
            val1 = plane[i].second;
            val2 = obs[2];
        }

        if ((val1 == 0 && val2 < val1)
            || (val1 != 0 && val2 > val1)) {
                sum += a[i];
            }

    }

    cout << sum;

    return 0;
}

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <iomanip>

#include <map>
#include <queue>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main()

{
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
int a,b,c;
int d,e,f;
cin>>a>>b>>c;
cin>>d>>e>>f;
int g1,g2,g3,g4,g5,g6;
cin>>g1>>g2>>g3>>g4>>g5>>g6;
int ans = 0;
if(b<0)
    ans+=g1;
if(a<0)
    ans+=g5;
if(c<0)
    ans+=g3;
if(a>d)
    ans+=g6;
if(b>e)
    ans+=g2;
if(c>f)
    ans+=g4;

cout<<ans;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define inf 200000000000000
#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define debug(x) cout<<#x<<": "<<x<<endl;
#define mod 1000000007
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ll t = 1;
    // cin>>t;
    while(t--){
        int x,y,a,b,c,z;
        cin>>x>>y>>z>>a>>b>>c;
        int val[6];
        rep(i,6){
            cin>>val[i];
        }
        int sum = 0;
        if(x<0){
            sum += val[4];
        }
        else if(x>a){
            sum += val[5];
        }
        // else if(x>0 && x<a){
        //     sum += val[4] + val[5];
        // }
        if(y<0){
            sum += val[0];
        }
        else if(y>b){
            sum += val[1];
        }
        // else if(y>0 && y<b){
        //     sum += val[0] + val[1];
        // }
        if(z<0){
            sum += val[2];
        }
        else if(z>c){
            sum += val[3];
        }
        // else if(z>0 && z<c){
        //     sum += val[2] + val[3];
        // }
        cout<<sum;
    }
}

//g++ -std=c++11 -Wall t.cpp -o test -lm -g -O2
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl '\n'
#define teto(a, b) (a+b-1)/(b)

const int MAX = 400010;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-25;
const ld PI = acosl(-1.0);

using namespace std;

int main()
{sws;

    int x, y, z;
    int x1, y1, z1;
    int a[10];

    cin >> x >> y >> z;
    cin >> x1 >> y1 >> z1;

    for(int i=1;i<=6;i++)
        cin >> a[i];

    // check for each case

    int resp = 0;

    if(y<0)
        resp+=a[1];
    if(y>y1)
        resp+=a[2];

    if(z<0)
        resp+=a[3];
    if(z>z1)
        resp+=a[4];

    if(x<0)
        resp+=a[5];
    if(x>x1)
        resp+=a[6];

    cout << resp << endl;

    return 0;
}

#include<bits/stdc++.h>
#include<fstream>
#define prime 1000000007
#define mod 998244353
#define pb push_back
#define no 100000000
#define mp make_pair
#define forn(i,a,b) for (int i = a; i <b; i++)
#define fornn(i,a,b) for (int i = a; i <=b; i++)
#define num 1000000000
#define INF INT_MAX
typedef long long ll;
using namespace std;

#define WINPAUSE system("pause")

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
ll max(ll a,ll b)
{
  if(b>a)
   return b;
   else
   {
     return a;
   }

}
ll power(ll x, ll y, ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}
ll factorial[500005];

void swap(int* a, int* b)
{
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}
 void DFSU(int n,vector<int> b[],int i,int visited[],int a[])
{

     if(visited[i]==0)
      {unordered_map<int,int> u;
      u.insert(mp(a[i],1));
        visited[i]=1;
        for(int j=0;j<b[i].size();j++)
        {   if(u.find(a[b[i][j]])!=u.end())
                 {visited[0]=-1;
                   break;
                 }
          u.insert(mp(a[b[i][j]],1));

                DFSU(n,b,b[i][j],visited,a);
        }
      }

}
int DFS(int n,vector<int> b[],int visited[],int a[])
  {int count=0;

    fornn(i,1,n)
    {
      if(visited[i]==0)
       {
         count++;
         DFSU(n,b,i,visited,a);
       }
       if(visited[0]==-1)
     return -1;
    }

    return count;
  }
//int visited[500005];
int c[100005];

//int a[100005],s[100005],m[100005];
int main()
 { ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     freopen("log.txt", "w", stderr);
    #endif
    int x,y,z,x1,y1,z1;
    cin>>x>>y>>z>>x1>>y1>>z1;
    int a[6];
    forn(i,0,6)
     cin>>a[i];
    int  sum=0;
    if(x<0)
     sum+=a[4];
    else if(x>x1)
    {
      sum+=a[5];
    }
    if(y<0)
     sum+=a[0];
    else if(y>y1)
    {
      sum+=a[1];
    }
    if(z<0)
     sum+=a[2];
    else if(z>z1)
    {
      sum+=a[3];
    }
    cout<<sum<<endl;
 //WINPAUSE;
     return 0;

}

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cctype>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <list>
#include <cstring>
using namespace std;

#pragma region defines

typedef long long ll;
typedef unsigned long long ull;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
const double PI = 3.14159265358979;
const double PI2 = 6.28318530717958;
const double PId2 = 1.570796326794895;
#define REP(to, counter) for (int counter=0; counter < int(to); counter++)
#define X first
#define Y second
#define eps 1E-7
inline vi ReadVI(int count) {vi arrayname(count); REP(count, i) cin >> arrayname[i]; return arrayname; };
inline vii ReadVII(int count) {vii arrayname(count); REP(count, i) {cin >> arrayname[i].first; arrayname[i].second = i; } return arrayname; };
#pragma endregion defines
const int MOD = 1000000007;
const int MAXVALUE = 100001;

int main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	double beginTime=clock();
#endif
	int x,y,z, xb, yb, zb, a, b, c, d, e, f;
	cin >> x >> y >> z >> xb >> yb >> zb >> a >> b >> c >> d >> e >> f;
	int ans = 0;
	if (x > xb) ans += f;
	if (x < 0) ans += e;
	if (y > yb) ans += b;
	if (y < 0) ans += a;
	if (z > zb) ans += d;
	if (z < 0) ans += c;
	cout << ans;

#ifndef ONLINE_JUDGE
	double endTime=clock();
	printf("\n***Elapsed = %.5lf******", (endTime-beginTime)/CLOCKS_PER_SEC);
#endif
}

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define pb push_back
#define mp make_pair
#define f_inp ios_base::sync_with_stdio(false)
#define testcase int test_case;cin>>test_case;while(test_case--)
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define mod 1000000007
#define lim 100005

/*sdfsd*/

int main()
{
    f_inp;
    int x,y,z,x1,y1,z1;
    int a[6];
    cin>>x>>y>>z>>x1>>y1>>z1>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5];
    int look[6] = {0};
    if(y<0) look[0]=1;
    if(y>y1) look[1]=1;
    if(z<0) look[2]=1;
    if(z>z1) look[3]=1;
    if(x<0) look[4]=1;
    if(x>x1) look[5]=1;
    int ans = 0;
    for(int i=0;i<6;i++) if(look[i]) ans+=a[i];
    cout<<ans;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int x1,y1,z1,ans,x,y,z;
long long a[1000005];
int main(){
	cin>>x>>y>>z>>x1>>y1>>z1;
	for(int i=1;i<=6;i++) cin>>a[i];
	if(y<0) ans+=a[1];
	if(y>y1) ans+=a[2];
	if(z<0) ans+=a[3];
	if(z>z1) ans+=a[4];
	if(x<0) ans+=a[5];
	if(x>x1) ans+=a[6];
	cout<<ans<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define For(i, a, b) for (int (i) = (a); (i) <= (b); (i) ++)
#define db(x) cout << #x << " = " << (x) << endl;
#define dba(a, x, y){cout << #a << " :";For(i, (x), (y))cout<<" "<<(a)[(i)];cout<<endl;}
#define dbp(p){cout << #p << " = (" << p.first << " " << p.second << endl;}
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;

int X, Y, Z, x, y, z, a[10];
int main()
{
	ios_base::sync_with_stdio(0); cout.precision(15);
    cin >> x >> y >> z;
    cin >> X >> Y >> Z ;
    rep1(i, 6) cin >> a[i];
    int ans = 0;
    if (y < 0)
        ans += a[1];
    if (y > Y)
        ans += a[2];
    if (z < 0)
        ans += a[3];
    if (z > Z)
        ans += a[4];
    if (x < 0)
        ans += a[5];
    if (x > X)
        ans += a[6];
    cout << ans << endl;

}

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <limits.h>
#define fo(i,n) for(i=0;i<n;++i)
#define forr(i,n) for(i=n-1;i>=0;--i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int main(){
    int x, y, z;
    int x1, y1, z1;
    int a1, a2, a3, a4, a5, a6;
    cin>>x>>y>>z;
    cin>>x1>>y1>>z1;
    cin>>a1>>a2>>a3>>a4>>a5>>a6;

    int res = 0;
    if(x>x1)res+=a6;
    if(x<0) res+=a5;
    if(y>y1)res+=a2;
    if(y<0) res+=a1;
    if(z>z1)res+=a4;
    if(z<0) res+=a3;

    cout<<res<<endl;
    return 0;
}

#include <stdio.h>
#include <vector>
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <set>
#include <queue>
#include <deque>
using namespace std;
int p[1000005];

int main(){
   //freopen(TASK".in", "r", stdin); freopen(TASK".out", "w", stdout);
    int x,y,z,a,b,c;
    vector<int>vec(6);
    cin >> x >> y >> z >> a >> b >> c;
    for(int i=0; i<6; ++i) scanf("%d", &vec[i]);
    int res=0;
    if(y > b) res+=vec[1];
    if(y < 0) res+=vec[0];
    if(z < 0) res+=vec[2];
    if(z > c) res+=vec[3];
    if(x > a) res+=vec[5];
    if(x < 0) res+=vec[4];
    cout << res;
    //system("pause");
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

#define PB push_back
#define FRO freopen("in.txt","r",stdin);

#define CLR(arr) memset( (arr),0,sizeof(arr) );
#define NEG(arr) memset( (arr),-1,sizeof(arr) );
#define ALL(v) v.begin(),v.end()

#define X first
#define Y second
#define MP make_pair

typedef pair<int,int> pint;
typedef map<int,int> mint;

void show() {cout<<'\n';}
template<typename T,typename... Args>
void show(T a, Args... args) { cout<<a<<" "; show(args...); }
template<typename T>
void show_c(T& a) { for ( auto &x:a ){ cout<<x<<" ";}cout<<endl;  }

int dy[2];
int dz[2];
int dx[2];

int main(){

    int x,y,z;
    cin>>x>>y>>z;

    int a,b,c;
    cin>>a>>b>>c;

    cin>>dy[0]>>dy[1];
    cin>>dz[0]>>dz[1];
    cin>>dx[0]>>dx[1];

    int ans = 0;

    if ( x > a ){
        ans += dx[1];
    }if ( x<0 ){
        ans += dx[0];
    }

    if ( y > b ){
        ans += dy[1];
    }if ( y<0 ){
        ans += dy[0];
    }

    if ( z > c ){
        ans += dz[1];
    }if ( z<0 ){
        ans += dz[0];
    }

    cout<<ans<<endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;

int main()
{
   int x,y,z;
   int mx,my,mz;
   int sy1,sy2,sz1,sz2,sx1,sx2;
   cin >> mx >> my >> mz;
   cin >> x >> y >> z;
   cin >> sy1 >> sy2 >> sz1 >> sz2 >>sx1 >> sx2;
   int ans = 0;
   if(mx < 0)ans += sx1;
   if(mx > x)ans += sx2;

   if(my < 0)ans += sy1;
   if(my > y)ans += sy2;

   if(mz < 0)ans += sz1;
   if(mz > z)ans += sz2;
   cout << ans << "\n";
    return 0;
}

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <limits.h>
#define fo(i,n) for(i=0;i<n;++i)
#define forr(i,n) for(i=n-1;i>=0;--i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

int main(){
    int x, y, z;
    int x1, y1, z1;
    int a1, a2, a3, a4, a5, a6;
    cin>>x>>y>>z;
    cin>>x1>>y1>>z1;
    cin>>a1>>a2>>a3>>a4>>a5>>a6;

    if(x>x1 &&  y>y1 && z>z1){
        cout<<a2+a4+a6<<endl;
        return 0;
    }

    if(x>x1 && y>y1 && z<0){
        cout<<a2+a3+a6<<endl;
        return 0;
    }

    if(x>x1 && z>z1 && y<0){
        cout<<a1+a4+a6<<endl;
        return 0;
    }

    if(y>y1 && z>z1 && x<0){
        cout<<a2+a4+a5<<endl;
        return 0;
    }

    if(x<0 && y<0 && z>z1){
        cout<<a1+a4+a5<<endl;
        return 0;
    }

    if(x<0 && z<0 && y>y1){
        cout<<a2+a3+a5<<endl;
        return 0;
    }

    if(y<0 && z<0 && x>x1){
        cout<<a1+a3+a6<<endl;
        return 0;
    }

    if(x<0 && y<0 && z<0){
        cout<<a1+a3+a5<<endl;
        return 0;
    }

    if(x>x1 && y>y1){// && z==z1/2){
        cout<<a2+a6<<endl;
        return 0;
    }

    if(x>x1 && y<0){// && z==z1/2){
        cout<<a1+a6<<endl;
        return 0;
    }

    if(x<0 && y>y1){// && z==z1/2){
        cout<<a2+a5<<endl;
        return 0;
    }

    if(x<0 && y<0){// && z==z1/2){
        cout<<a1+a5<<endl;
        return 0;
    }

    if(x>x1 && z>z1){// && y==y1/2){
        cout<<a4+a6<<endl;
        return 0;
    }

    if(x>x1 && z<0){// && y==y1/2){
        cout<<a3+a6<<endl;
        return 0;
    }

    if(x<0 && z>z1){// && y==y1/2){
        cout<<a4+a5<<endl;
        return 0;
    }

    if(x<0 && z<0){// && y==y1/2){
        cout<<a3+a5<<endl;
        return 0;
    }

    if(y>y1 && z>z1){// && x==x1/2){
        cout<<a2+a4<<endl;
        return 0;
    }

    if(y>y1 && z<0){// && x==x1/2){
        cout<<a2+a3<<endl;
        return 0;
    }

    if(y<0 && z>z1){// && x==x1/2){
        cout<<a1+a4<<endl;
        return 0;
    }

    if(y<0 && z<0){// && x==x1/2){
        cout<<a1+a3<<endl;
        return 0;
    }

    // if(x==x1/2 && z==z1/2){
        if(y>y1){
            cout<<a2<<endl;
            return 0;
        }
        if(y<0){
            cout<<a1<<endl;
            return 0;
        }
    // }

    // if(x==x1/2 && y==y1/2){
        if(z>z1){
            cout<<a4<<endl;
            return 0;
        }
        if(z<0){
            cout<<a3<<endl;
            return 0;
        }
    // }

    // if(y==y1/2 && z==z1/2){
        if(x>x1){
            cout<<a6<<endl;
            return 0;
        }
        else{
            cout<<a5<<endl;
            return 0;
        }
    // }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i,n) for(int i=0;i<n;i++)
#define foo(i,a,b) for(int i=a;i<b;i++)
#define mp make_pair
#define deb(x) cout<<#x<<"-->"<<x<<endl;
#define deb1a(v) for(auto it:v) {cout<<it<<" ";} cout<<endl;
#define deb2a(v) for(auto it:v){for(auto it1:it) {cout<<it1<<" ";}cout<<endl;}
int32_t main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int x,y,z,x1,x2,x3;
cin>>x>>y>>z>>x1>>x2>>x3;
vec v(6);
fo(i,6)
cin>>v[i];
int ans=0;
if(x>x1)
ans+=v[5];
if(x<0)
    ans+=v[4];
if(y>x2)
ans+=v[1];
if(y<0)
    ans+=v[0];
    if(z>x3)
ans+=v[3];
if(z<0)
    ans+=v[2];
    cout<<ans;

}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <map>
#include <iomanip>
#define PI acos(-1.0)
#define Max 2005
#define inf 1<<28
#define LL(x) (x<<1)
#define RR(x)(x<<1|1)
using namespace std;

int main()
{
    int x,y,z;
    int x1,y1,z1;
    int a[7];
    int sum=0;
    scanf("%d%d%d",&x,&y,&z);
    scanf("%d%d%d",&x1,&y1,&z1);
    for(int i=1;i<=6;i++)
    {
        scanf("%d",&a[i]);
    }
    if(x>x1)
        sum+=a[6];
    if(x<0)
        sum+=a[5];
    if(y>y1)
        sum+=a[2];
    if(y<0)
        sum+=a[1];
    if(z>z1)
        sum+=a[4];
    if(z<0)
        sum+=a[3];
    cout<<sum<<endl;
    return 0;
}

/*ssgfskhhlaflsekbcnlgmgqojrqahodgekddakkdlipbmrchlg*/

#include<cstdio>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<cstring>
#include<cmath>
#include<iostream>
#include<iomanip>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define RE(i,n) for(int i=0,_n=(n);i<_n;++i)
#define RI(i,n) for(int i=1,_n=(n);i<=_n;++i)
#define mini(a,b) a=min(a,(b))
#define maxi(a,b) a=max(a,(b))
#define all(w) w.begin(),w.end()
const int inf=1e9+5,nax=1e6+5;

struct P {
	int x;
	int y;
	int z;
	void Wczytaj() {
		cin >> x >> y >> z;
	}
};

P Minus(P a, P b) {
	a.x -= b.x;
	a.y -= b.y;
	a.z -= b.z;
	return a;
}

int main()
{
	P punkt;
	punkt.Wczytaj();
	P t;
	t.Wczytaj();
	int res = 0;
	int a;

	cin >> a;
	if(punkt.y < 0) res += a;
	cin >> a;
	if(punkt.y > t.y) res += a;

	cin >> a;
	if(punkt.z < 0) res += a;
	cin >> a;
	if(punkt.z > t.z) res += a;

	cin >> a;
	if(punkt.x < 0) res += a;
	cin >> a;
	if(punkt.x > t.x) res += a;

	cout << res;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define sd(x) 		scanf("%d",&x)
#define su(x) 		scanf("%u",&x)
#define slld(x) 	scanf("%lld",&x)
#define sc(x) 		scanf("%c",&x)
#define ss(x) 		scanf("%s",x)
#define sf(x) 		scanf("%f",&x)
#define slf(x)		scanf("%lf",&x)
#define ll 			long long int
#define mod(x,n) 	(x+n)%n
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define Mod         1000000007

double x2,y2,z2;

bool inside(double x, double y, double z)
{
	if( 0<=x && x<=x2 && 0<=y && y<=y2 &&  0<=z && z<=z2 )
		return true;
	return false;
}

bool chk(double x,double y,double z,double x1,double y1,double z1)
{
	while( (x1-x)*(x1-x) + (y1-y)*(y1-y) + (z1-z)*(z1-z) > 0.00001 )
	{
		if( inside(x,y,z) )
			return false;
		x = (x1+x)/2;	y = (y1+y)/2;	z = (z1+z)/2;
	}
	return true;
}

int A[10];

int main()
{
	// freopen("input_file_name.in","r",stdin);
	// freopen("output_file_name.out","w",stdout);

	int i,j,k,l,m,n,a,b;
	// ll i,j,k,l,m,n,x,y,z,a,b,r;
	double x,y,z;

	slf(x);	slf(y);	slf(z);
	slf(x2);	slf(y2);	slf(z2);

	for(i=0;i<6;i++)
		sd(A[i]);

	a = 0;

	if( chk(x,y,z,x2/2,0,z2/2) )
	{
		// printf("*1\n");
		a += A[0];
	}

	if( chk(x,y,z,x2/2,y2,z2/2) )
	{
		// printf("*2\n");
		a += A[1];
	}

	if( chk(x,y,z,x2/2,y2/2,0) )
	{
		// printf("*3\n");
		a += A[2];
	}

	if( chk(x,y,z,x2/2,y2/2,z2) )
	{
		// printf("*4\n");
		a += A[3];
	}

	if( chk(x,y,z,0,y2/2,z2/2) )
	{
		// printf("*5\n");
		a += A[4];
	}

	if( chk(x,y,z,x2,y2/2,z2/2) )
	{
		// printf("*6\n");
		a += A[5];
	}

	printf("%d\n", a );

	return 0;
}

#include <bits/stdc++.h>
#define ll long long

using namespace std;

const ll MXN = 1e5 + 7;
const ll MOD = 1e9 + 7;

void perday(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int x0, y0, z0, x, y, z, sum, a[7];

int main(){
    perday();
    cin >> x0 >> y0 >> z0;
    cin >> x >> y >> z;
    for(int i = 1; i <= 6; i++){
        cin >> a[i];
    }
    if(z0 > z){
        sum += a[4];
    }
    else if(z0 < 0){
        sum += a[3];
    }
    if(y0 > y){
        sum += a[2];
    }
    else if(y0 < 0){
        sum += a[1];
    }
    if(x0 > x){
        sum += a[6];
    }
    else if(x0 < 0){
        sum += a[5];
    }
    cout << sum;
}

#include <iostream>
#include <string>
#include <math.h>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_set>
#include <set>
#include <stack>
#include <limits>
#include <queue>
#include <list>
#include <cstring>
#include <bitset>

using namespace std;

int main() {

    long long a, b, c;

    long long x, y, z;

    cin >> x >> y >> z;
    cin >> a >> b >> c;
    long long v[6];
    cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4] >> v[5];
    long long res = 0;
    if (y < 0) res += v[0];
    if (y > b) res += v[1];
    if (z < 0) res += v[2];
    if (z > c) res += v[3];
    if (x < 0) res += v[4];
    if (x > a) res += v[5];
    cout << res << endl;

}

#include<bits/stdc++.h>

using namespace std;

int main() {

#ifndef ONLINE_JUDGE

    freopen("in.in", "r", stdin);

//    freopen("out.out", "w", stdout);

#endif

	int x,y,z,x1,y1,z1,a1,a2,a3,a4,a5,a6;

	cin>>x>>y>>z>>x1>>y1>>z1;

	cin>>a1>>a2>>a3>>a4>>a5>>a6;

	int ans=0;

	if(x<0) ans+=a5;

	if(x>x1) ans+=a6;

	if(y<0) ans+=a1;

	if(y>y1) ans+=a2;

	if(z<0) ans+=a3;

	if(z>z1) ans+=a4;

	printf("%d\n",ans);

}

#include <iostream>

using namespace std;

int main()
{
    int s=0,x,y,z,x1,y1,z1,cord[6];
    cin>>x>>y>>z;
    cin>>x1>>y1>>z1;
    for(int i=0;i<6;++i){cin>>cord[i];}
    if(z>z1){s=s+cord[3];}
    if(x<0){s=s+cord[4];}
    if(x>x1){s=s+cord[5];}
    if(z<0){s=s+cord[2];}
    if(y>y1){s=s+cord[1];}
    if(y<0){s=s+cord[0];}
    cout<<s<<endl;
    return 0;}

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <cstdio>

#define MAXN 120
#define pb push_back
#define mk make_pair
#define F first
#define S second

using namespace std;

int x, y, z, xx, yy, zz, ans;
int a[20];

int main(){
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	cin >> x >> y >> z;

	cin >>xx >> yy>> zz;

	for (int i = 1; i <= 6; i++)
	cin >> a[i];

	if (x < 0)	ans += a[5];
	else
	if (x > xx) ans += a[6];
	if (z < 0) ans += a[3];
	else
	if (z > zz) ans += a[4];

	if (y < 0)	ans += a[1];
	else
	if (y > yy) ans += a[2];

	cout << ans;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main()
{
   int x1,y1,z1,x,y,z;
   int a,b,c,d,e,f;
   cin>>x1>>y1>>z1>>x>>y>>z>>a>>b>>c>>d>>e>>f;
   int ans=0;
   if(y1>y){

   ans+=b;}
   if(y1<0)
   {
   ans+=a;}
   if(z1>z)
   {
   ans+=d;}
   if(z1<0)
   {
   ans+=c;
   }
   if(x1>x){
   ans+=f;
   }
   if(x1<0)
   {
   ans+=e;}
   cout<<ans;

   return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int person[3];
    for(int i = 0 ; i < 3 ;i++){
        cin >> person[i];
    }
    int square[3];
    for(int i = 0 ; i < 3 ;i++){
        cin >> square[i];
    }
    int faces[6];
    for(int i = 0 ;i < 6 ; i++){
        cin >> faces[i];
    }
    long sum=0;
    if(person[0]>square[0]){
        sum+=faces[5];
    }else if(person[0]<0){
    sum+=faces[4];}
    if(person[1]>square[1]){
        sum+=faces[1];
    }else if(person[1]<0){
    sum+=faces[0];}
    if(person[2]>square[2]){
        sum+=faces[3];
    }else if(person[2]<0){
    sum+=faces[2];}
    cout << sum;
    return 0;
}

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<int> v(6);
    int a,b,c;
    int x,y,z;

    cin>>x>>y>>z>>a>>b>>c;
    for(int i=0;i<6;i++)
        cin>>v[i];

    int sum=0;

    if(y<0)
        sum+=v[0];
    if(y>b)
        sum+=v[1];
    if(z<0)
        sum+=v[2];
    if(z>c)
        sum+=v[3];
    if(x<0)
        sum+=v[4];
    if(x>a)
        sum+=v[5];

    cout<<sum<<"\n";
    return 0;
}

// saihemanth9019
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define foi(i,a,n) for(i = (a); i <= (n); i++)
#define pd(x) cout<<x
#define sd(x) cin>>x
#define nl cout<<endl
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//ll fibonacci[2][2] = {{0,1},{1,1}};
//ll identity[2][2] = {{1,0},{0,1}};

int main() {
	ll i,j,k;
	ll x,y,z;
	cin>>x>>y>>z;
	ll x1,y1,z1;
	cin>>x1>>y1>>z1;
	ll a1, a2, a3, a4, a5, a6;
	cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6;
	ll ans = 0;

	if (y < 0) ans += a1;
	if (y > y1) ans += a2;
	if (z < 0) ans += a3;
	if (z > z1) ans += a4;
	if (x < 0) ans += a5;
	if (x > x1) ans += a6;

	cout << ans << endl;
	return 0;
}

#include <stdio.h>
#include <math.h>

#define M_PI_2 1.57079632679489661923

struct vector3D
{
  double x, y, z;
};

int a[6];
vector3D viewPos;
vector3D coords;
vector3D normals[6];

void ReadData()
{
  scanf("%lf %lf %lf", &viewPos.x, &viewPos.y, &viewPos.z);
  scanf("%lf %lf %lf", &coords.x, &coords.y, &coords.z);
  for(int i = 0; i < 6; i++)
  {
    scanf("%d", &a[i]);
  }
}

double getLen(vector3D &vec)
{
  return abs(sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z));
}

double getAngle(vector3D &vec1, vector3D &vec2)
{
  double result = vec1.x * vec2.x + vec1.y * vec2.y + vec1.z * vec2.z;
  result /= getLen(vec1) * getLen(vec2);
  return result;
}

int answer;

void Solve()
{
  answer = 0;
  vector3D w;
  w.x = viewPos.x - coords.x / 2.0;
  w.y = viewPos.y;
  w.z = viewPos.z - coords.z / 2.0;
  if(acos(getAngle(normals[0], w)) < M_PI_2)
    answer += a[0];
  w.x = viewPos.x - coords.x / 2.0;
  w.y = viewPos.y - coords.y;
  w.z = viewPos.z - coords.z / 2.0;
  if(acos(getAngle(normals[1], w)) < M_PI_2)
    answer += a[1];

  w.x = viewPos.x - coords.x / 2.0;
  w.y = viewPos.y - coords.y / 2.0;
  w.z = viewPos.z;
  if(acos(getAngle(normals[2], w)) < M_PI_2)
    answer += a[2];
  w.x = viewPos.x - coords.x / 2.0;
  w.y = viewPos.y - coords.y / 2.0;
  w.z = viewPos.z - coords.z;
  if(acos(getAngle(normals[3], w)) < M_PI_2)
    answer += a[3];

  w.x = viewPos.x;
  w.y = viewPos.y - coords.y / 2.0;
  w.z = viewPos.z - coords.z / 2.0;
  if(acos(getAngle(normals[4], w)) < M_PI_2)
    answer += a[4];
  w.x = viewPos.x - coords.x;
  w.y = viewPos.y - coords.y / 2.0;
  w.z = viewPos.z - coords.z / 2.0;
  if(acos(getAngle(normals[5], w)) < M_PI_2)
    answer += a[5];
}

void WriteData()
{
  printf("%d\n", answer);
}

int main()
{
  normals[0].x = 0, normals[0].y = -1, normals[0].z = 0;
  normals[1].x = 0, normals[1].y = 1, normals[1].z = 0;

  normals[2].x = 0, normals[2].y = 0, normals[2].z = -1;
  normals[3].x = 0, normals[3].y = 0, normals[3].z = 1;

  normals[4].x = -1, normals[4].y = 0, normals[4].z = 0;
  normals[5].x = 1, normals[5].y = 0, normals[5].z = 0;
  int QWE;
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  scanf("%d", &QWE);
  #else
  QWE = 1;
  #endif
  for(int T = 0; T < QWE; T++)
  {
    ReadData();
    Solve();
    WriteData();
  }
  return 0;
}

//lxrtxdy!
//g++ -std=c++11 -Wall t.cpp -o test -lm -g -O2
#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl '\n'
#define teto(a, b) (a+b-1)/(b)

const int MAX = 400010;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-25;
const ld PI = acosl(-1.0);

using namespace std;

int main()
{sws;

    int x, y, z;
    int x1, y1, z1;
    int a[10];

    cin >> x >> y >> z;
    cin >> x1 >> y1 >> z1;

    for(int i=1;i<=6;i++)
        cin >> a[i];

    // check for each case

    int resp = 0;

    if(y<0)
        resp+=a[1];
    if(y>y1)
        resp+=a[2];

    if(z<0)
        resp+=a[3];
    if(z>z1)
        resp+=a[4];

    if(x<0)
        resp+=a[5];
    if(x>x1)
        resp+=a[6];

    cout << resp << endl;

    return 0;
}

//orzlxr!//hello

//template
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cmath>
#include <ctime>
#include <cfloat>
#include <string.h>
#include <memory.h>
using namespace std;
#define              FOR(i,a,b)  for(int i=int(a);i<int(b);++i)
#define                       X  first
#define                       Y  second
#define                 MP(a,b)  make_pair(a,b)
typedef               long long  ll;
typedef       pair < int, int >  pii;
typedef         pair < ll, ll >  pll;
typedef pair < double, double >  pdd;
typedef          vector < int >  vi;
typedef           vector < ll >  vll;
typedef       vector < string >  vs;
typedef             set < int >  si;
typedef              set < ll >  sll;
typedef          set < string >  ss;
inline double sqr( double x ) { return x*x; }
#pragma comment(linker, "/STACK:16777216")
//template
int x, y, z, a, b, c, v[6], res = 0;

bool r(ll x1, ll y1, ll z1, ll x2, ll y2, ll z2) {
   ll a, b, c, f, g;
   a = x2 - x1;
   b = y2 - y1;
   c = z2 - z1;

   f = a*(x-x2) + b*(y-y2) + c*(z-z2);
   g = a*(x1-x2) + b*(y1-y2) + c*(z1-z2);

   if( !f )
      return false;

   return (f > 0) ^ (g > 0);
}

int main() {
   #ifdef _DEBUG
   freopen("in.txt","rt",stdin);
   #endif

   cin >> x >> y >> z >> a >> b >> c;
   FOR(i,0,6) cin >> v[i];

   if( r(0,b,0,0,0,0) )
      res += v[0];

   if( r(0,0,0,0,b,0) )
      res += v[1];

   if( r(0,0,c,0,0,0) )
      res += v[2];

   if( r(0,0,0,0,0,c) )
      res += v[3];

   if( r(a,0,0,0,0,0) )
      res += v[4];

   if( r(0,0,0,a,0,0) )
      res += v[5];

   cout << res;
   return 0;
}

#include<bits/stdc++.h>
using namespace std;

int a,b,c,x,y,z,aa[14],sum;

int main()
{
    cin>>a>>b>>c;
    cin>>x>>y>>z;
    cin>>aa[1]>>aa[2]>>aa[3]>>aa[4]>>aa[5]>>aa[6];
    /*
    if(a>=x&&b>=y&&c>=z)
        {
            sum = aa[2] + aa[4] + aa[6];
        }
        else if(a>=x&&b<y&&c<z)sum = aa[6];
        else if(a<x&&b<y&&c>=z)sum = aa[4];
        else if(a<x&&b>=y&&c<z)sum = aa[2];
        else if(a<x&&b>=y&&c>=z)sum = aa[2]+aa[4];
        else if(a>=x&&b<y&&c>=z)sum = aa[4]+aa[6];
        else if(a>=x&&b>=y&&c<z)sum = aa[6]+aa[2];

    */
    if(a<0)sum=aa[5];
    else if(a>x){sum = aa[6];}

    if(b>y){sum += aa[2];}
    else if(b<0)sum+=aa[1];

    if(c>z)sum+=aa[4];
    else if(c<0)sum+=aa[3];

    cout<<sum;

   return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <queue>
#include<set>
using namespace std;

int main(){
    long long x, y, z;
    cin >> x>>y>>z;
    long long x1, y1, z1;
    cin >> x1 >> y1 >> z1;
    long long ans = 0;
    long long a;
    cin >> a;
    if (y<0) ans += a;
    cin >> a;
    if (y>y1) ans += a;
    cin >> a;
    if (z < 0) ans += a;
    cin >> a;
    if (z>z1) ans += a;
    cin >> a;
    if (x < 0) ans += a;
    cin >> a;
    if (x>x1) ans += a;
    cout << ans <<  endl;
    //system("PAUSE");
    return 0;
}

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define pb push_back
#define mp make_pair
#define f_inp ios_base::sync_with_stdio(false)
#define testcase int test_case;cin>>test_case;while(test_case--)
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define mod 1000000007
#define lim 100005

/*sdfsd*/

int main()
{
    f_inp;
    int x,y,z,x1,y1,z1;
    int a[6];
    cin>>x>>y>>z>>x1>>y1>>z1>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5];
    int look[6] = {0};
    if(y<0) look[0]=1;
    if(y>y1) look[1]=1;
    if(z<0) look[2]=1;
    if(z>z1) look[3]=1;
    if(x<0) look[4]=1;
    if(x>x1) look[5]=1;
    int ans = 0;
    for(int i=0;i<6;i++) if(look[i]) ans+=a[i];
    cout<<ans;
    return 0;
}

#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll ,ll >
#define vi          vector<ll int>
#define vii         vector<pii>
#define mi          map<ll int,ll int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define take        rep(i,0,n) cin>>v[i];
#define MAXN        2000005

using namespace std;

void solve()
{
	ll xx,yy,zz,x,y,z;
	cin>>xx>>yy>>zz;
	x=abs(xx);
	y=abs(yy);
	z=abs(zz);
	ll a,b,c;
	cin>>a>>b>>c;
	vi v(7);
	for(ll i=1;i<=6;i++)
	{
		cin>>v[i];
	}
	if(xx>=0&&yy>=0&&zz>=0&&xx<=a&&yy<=b&&zz<=c)
	{
		cout<<0<<endl;
		return;
	}
	ll xc=0,yc=0,zc=0;
	ll cc=0;
	if(zz>c)
	{
		cc=cc+v[4];

	}
	else if(zz<0)
	{
		cc=cc+v[3];
	}
	if(yy>b)
	{
		cc=cc+v[2];

	}
	else if(yy<0)
	{
		cc=cc+v[1];
	}
	if(xx>a)
	{
		cc=cc+v[6];
	}
	else if(xx<0)
	{
		cc=cc+v[5];

	}

	cout<<cc<<endl;

}
int main()
    {
      ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t;
        t=1;

     //   sieve();
   // cin>>t;
        while(t--)
        solve();
    }

#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <string.h>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <numeric>
#include <utility>
#include <cctype>
#include <list>
#include <climits>
#include <signal.h>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define ll long long int
int main( ) {
    ll i, j, k, ct=0, m, n, t, x, y, z, x1,y1,z1, a1,a2,a3,a4,a5,a6;
    double a, b, c, d;
    char p, q, r, s;
    string str, s1, s2, s3;
    map<int, int> mp;
    vector<int> v;
    cin >> x >> y >> z;
    cin >> x1 >> y1 >> z1;
    cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6;
    ct  = 0;
    if(y > y1){
        ct += a2;
    }
    if(y < 0){
        ct += a1;
    }
    if(x > x1){
        ct += a6;
    }
    if(x < 0){
        ct+=a5;
    }
    if(z < 0){
        ct += a3;
    }
    if(z > z1){
        ct+= a4;
    }
    cout << ct;
    return 0;
}

#include<set>
#include<cmath>
#include<stack>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<numeric>
#include<vector>
#include<ctime>
#include<queue>
#include<list>
#include<map>
#define pi acos(-1)
#define INF 0x7fffffff
#define clr(x)  memset(x,0,sizeof(x));
#define clrto(x,siz,y)  for(int xx=0;xx<=siz;xx++)  x[xx]=y;
#define clrset(x,siz)  for(int xx=0;xx<=siz;xx++)  x[xx]=xx;
#define clrvec(x,siz) for(int xx=0;x<=siz;xx++)  x[xx].clear();
#define fop   freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
#define myprogram By_135678942570
#define clrcpy(x,siz,y)  for(int xx=0;xx<siz;xx++)  x[xx]=y[xx];
using namespace std;
main()
{
     int a1,a2,a3,a4,a5,a6;
     int x,y,z;
     int x1,y1,z1;
     while(cin>>x>>y>>z)
     {
         cin>>x1>>y1>>z1;
         cin>>a1>>a2>>a3>>a4>>a5>>a6;
         int sum=0;
         if(z>z1)
            sum+=a4;
         if(z<0)
            sum+=a3;
         if(x>x1)
            sum+=a6;
         if(x<0)
            sum+=a5;
         if(y>y1)
            sum+=a2;
         if(y<0)
            sum+=a1;
         printf("%d\n",sum);
     }
     return 0;
}

//#define PROB "test"    //{{{ Preamble
#ifndef LOCAL_PC
#  define NDEBUG
#  define LOG(...) static_cast<void>(0)
#else
#  include <logging.hpp>
#endif
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
#  include <forward_list>
#  include <unordered_map>
#  include <unordered_set>
#endif
#include <ext/numeric>
using namespace std; typedef long long ll; typedef unsigned long long ull;
const double pi=3.14159265358979323846; const double E=2.7182818284590452354;
static struct _{ ios_base::Init i; _(){cin.sync_with_stdio(0);cin.tie(0);} } _;
template<class T>inline T sq(const T&x_){return x_*x_;} using __gnu_cxx::power;
template<class I> inline void in(I d_, int n_) {do cin >> *d_++; while (--n_);}
#if defined(PROB) && !defined(LOCAL_PC)
static struct __{ __(){cin.rdbuf(a.open(PROB".in",ios::in));cout.rdbuf(b.open(
PROB".out",ios::out));} ~__(){cin.rdbuf(0);cout.rdbuf(0);} filebuf a,b; } __;
#endif
#define endl         '\n'
#define pb(...)      push_back(__VA_ARGS__)
#define eb(...)      emplace_back(__VA_ARGS__)
#define sz(v)        static_cast<int>((v).size())
#define X            first
#define Y            second
#define FOREACH(i,c) for(__typeof__((c).begin())i=(c).begin();i!=(c).end();++i)
#define mp(x, y)     make_pair((x), (y))
//}}}

int main()
{
    int vx, vy, vz; cin >> vx >> vy >> vz;
    int x, y, z; cin >> x >> y >> z;
    int a[7]; in(a+1, 6);

    int sum = 0;

    if (vz < 0)
        sum += a[3];
    if (vz > z)
        sum += a[4];
    if (vx < 0)
        sum += a[5];
    if (vx > x)
        sum += a[6];
    if (vy < 0)
        sum += a[1];
    if (vy > y)
        sum += a[2];

    cout << sum << endl;
}

#include <iostream>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int x, y, z, x1, y11, z1;
int a[6];

int main() {
    cin >> x >> y >> z >> x1 >> y11 >> z1;
    for (int i = 0; i < 6; i++) {
        cin >> a[i];
    }
    int ans = 0;
    if (y < 0) {
        ans += a[0];
    }
    if (y > y11) {
        ans += a[1];
    }
    if (z < 0) {
        ans += a[2];
    }
    if (z > z1) {
        ans += a[3];
    }
    if (x < 0) {
        ans += a[4];
    }
    if (x > x1) {
        ans += a[5];
    }
    cout << ans << endl;
    return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<cstdio>
#include<math.h>
#include<cstdlib>
#include<map>
#include<utility>
#include<stack>
#include<fstream>
#include<set>
#include<queue>

using namespace std;
#define ll long long int
vector <ll> v;
vector <ll> v1;
vector <ll> v2;
const ll inf=100000000000005;

#define cincout ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define me(a,i) memset(a,i,sizeof(a))
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define printv(n,v) for(int i=0;i<n;i++)  {cout<<v[i]<<" ";}
#define vin(v,n,a) for(int i=0;i<n;i++)	{v.pb(a);cin>>v[i];}

int main()
	{
	cincout;
	int x,y,z,x1,y1,z1,a1,a2,a3,a4,a5,a6;
	int sum=0;
	cin>>x>>y>>z>>x1>>y1>>z1>>a1>>a2>>a3>>a4>>a5>>a6;
	if(y<0)
		sum+=a1;
	else if(y>y1)
		sum+=a2;
	if(z<0)
		sum+=a3;
  	else if(z>z1)
  		sum+=a4;
  	if(x<0)
  		sum+=a5;
  	else if(x>x1)
  		sum+=a6;
  	cout<<sum<<endl;
  	return 0;
  	}

#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll mod = 1e9+7;

struct xyz {
    double x,y,z;
};
int main()
{
    double x,y,z,x1,y1,z1;
    ll i;
    vector<xyz> face(7);
    vector<xyz> center(7);
    vector<ll> val(7);
    cin>>x>>y>>z;
    cin>>x1>>y1>>z1;
    for(i=1;i<=6;i++)
    {
        face[i].x = 0;
        face[i].y = 0;
        face[i].z = 0;
        cin>>val[i];
        center[i].x = 0;
        center[i].y = 0;
        center[i].z = 0;
    }
    face[1].y = -1;
    face[2].y = 1;
    face[3].z = -1;
    face[4].z = 1;
    face[5].x = -1;
    face[6].x = 1;

    //face centers
    center[1].x = x1/2.0;
    center[1].z = z1/2.0;
    center[2] = center[1];
    center[2].y = y1;
    center[3].x = x1/2.0;
    center[3].y = y1/2.0;
    center[4] = center[3];
    center[4].z = z1;
    center[5].y = y1/2.0;
    center[5].z = z1/2.0;
    center[6] = center[5];
    center[6].x = x1;

    ll sum = 0;
    for(i=1;i<=6;i++)
    {
        if((x-center[i].x)*face[i].x + (y-center[i].y)*face[i].y + (z-center[i].z)*face[i].z > 0)
        {
            sum+=val[i];
        }
    }

    cout<<sum<<"\n";
}

#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <deque>

using namespace std;

#define ll long long

const int maxn = 1 << 17;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int x, y, z, X, Y, Z, a[6];

	cin >> x >> y >> z;
	cin >> X >> Y >> Z;
	for (int i = 0; i < 6; i++)
		cin >> a[i];

	int ans = 0;
	if (y < 0)
		ans += a[0];
	if (y > Y)
		ans += a[1];
	if (z < 0)
		ans += a[2];
	if (z > Z)
		ans += a[3];
	if (x < 0)
		ans += a[4];
	if (x > X)
		ans += a[5];

	cout << ans;

	return 0;
}

#include <cstdio>
//#include <bits/stdc++.h>
#define maxn

//using namespace std;
int a1, a2, a3, a4, a5, a6;
int x, y, z, x1, y1, z1;

int main() {
	int ans = 0;

	scanf("%d%d%d%d%d%d%d%d%d%d%d%d", &x, &y, &z, &x1, &y1, &z1, &a1, &a2, &a3, &a4, &a5, &a6);

	if(x < 0) ans += a5;
	else if(x > x1) ans += a6;
	if(y < 0) ans += a1;
	else if(y > y1) ans += a2;
	if(z < 0) ans += a3;
	else if(z > z1) ans += a4;
	printf("%d", ans);
	return 0;
}

#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
int main()
{
   // freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    double x, y, z;
    cin >> x >> y >> z;
    double x1, y1, z1;
    cin >> x1 >> y1 >> z1;
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >>f;

    int ans = 0;
    if(y < 0) {ans += a; }//cout << a << endl;}
    if(y > y1) {ans += b;}//cout << b<< endl;}
    if(z < 0) {ans += c;}//cout << c<< endl;}
    if(z > z1) {ans += d;}//cout << d<< endl;}
    if(x < 0) {ans += e;}//cout << e<< endl;}
    if(x > x1) {ans += f;}//cout << f<< endl;}
    cout << ans;

    return 0;
}

#include <bits/stdc++.h>

#define int long long
using namespace std;

signed main() {
    // Turn off synchronization between cin/cout and scanf/printf
    ios_base::sync_with_stdio(false);
    // Disable automatic flush of cout when reading from cin cin.tie(0);
    cin.tie(0);

    int x, y, z, x1, y1, z1;
    cin >> x >> y >> z >> x1 >> y1 >> z1;
    int a[6];
    for (int i = 0; i < 6; ++i) {
        cin >> a[i];
    }

    int sum = 0;
    if(y<0){sum+=a[0];}
    if(z<0){sum+=a[2];}
    if(x<0){sum+=a[4];}
    if(y1<y){sum+=a[1];}
    if(z1<z){sum+=a[3];}
    if(x1<x){sum+=a[5];}

    cout << sum;
}

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	//freopen("out.txt","wt",stdout);

	int x,y,z,xv, yv, zv;
	int A[6];
	cin >> xv >>yv>>zv>>x>>y>>z;
	for(int i =0;i<6;i++)
		cin >> A[i];
	int s = 0;
	if(yv<0)
		s+=A[0];
	if(yv>y)
		s+=A[1];
	if(zv<0)
		s+=A[2];
	if(zv>z)
		s+=A[3];
	if(xv<0)
		s+=A[4];
	if(xv>x)
		s+=A[5];
	cout << s;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <list>
#include <vector>
#include <map>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <utility>
#include <set>
#include <numeric>
#include <fstream>
#include <ctime>
#include <climits>
using namespace std;
int main() {
	int x, y, z, x1, y1, z1;
	cin >> x1 >> y1 >> z1 >> x >> y >> z;
	int a[6]; for(int i = 0; i < 6; ++i) cin >> a[i];
	int ans = 0;
	if (y1 < 0) ans += a[0];
	if (y1 > y) ans += a[1];
	if (z1 < 0) ans += a[2];
	if (z1 > z) ans += a[3];
	if (x1 < 0) ans += a[4];
	if (x1 > x) ans += a[5];
	cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define rep(i,a,n) for(int i = a; i<n; i++)
#define per(i,a,n) for(int i = n-1; i>=a; i--)

int max(int a,int b){return a>b ? a:b;}
int min(int a,int b){return a<b ? a:b;}

const int INF = 1e9+7;

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int x,y,z;
  int x1,y1,z1;
  cin>>x>>y>>z>>x1>>y1>>z1;
  int crd[6];
  rep(i,0,6)cin>>crd[i];

  int res = 0;
  if(y<0)res += crd[0];
  if(y>y1)res += crd[1];
  if(z<0)res += crd[2];
  if(z>z1)res += crd[3];
  if(x<0)res += crd[4];
  if(x>x1)res += crd[5];
  cout<<res<<"\n";

}

#include<iostream>
#include<fstream>
using namespace std;
int sol,a1,a2,a3,a4,a5,a6,x1,y1,z1,x,y,z;
int main()
{

//    ifstream cin("date.in");
  //  ofstream cout("date.out");
        cin>>x1>>y1>>z1;
    cin>>x>>y>>z;

    cin>>a1>>a2>>a3>>a4>>a5>>a6;
    if(y1<0)
        sol+=a1;
    //cout<<sol;
    if(y1>y)
        sol+=a2;
    //cout<<sol;
    if(z1<0)
        sol+=a3;
    //cout<<sol;
    if(z1>z)
        sol+=a4;
    //cout<<sol;
    if(x1<0)
        sol+=a5;
    //cout<<sol;
    if(x1>x)
        sol+=a6;
    //cout<<sol;
    cout<<sol;
    return 0;
}

#include <bits/stdc++.h>

#define lp(i,n) for(int i=0; i<n; i++)
#define ll long long
#define pb push_back
#define  mp make_pair

#define EPS 1e-8
#define OO 100000000

#define on(i,n) i=i|(1<<n)
#define off(i,n) i=i& (~(1<<n))

using namespace std;

vector<int> black;
vector <int> white;
//0=white 1=black
int x,y;
int boxx,boxy,boxz;

bool samesign(int a,int b){
    if(a<=0 && b<=0)
    return true;

    if(a>=0 && b>=0) return true;

    return false;
}

bool inside(int x,int y,int z){

    if(abs(x)>abs(boxx)|| !samesign(x,boxx) ) return false;

    if(abs(y)>abs(boxy)||!samesign(y,boxy)) return false;

    if(abs(z)>abs(boxz)|| !samesign(z,boxz)) return false;
    return true;

}

int main(){

    int x,y,z;

    vector<int> a(7);

    cin>>x>>y>>z>>boxx>>boxy>>boxz;

    lp(i,6){
        cin>>a[i+1];
    }

    if(inside(x,y,z)){
        int sum=0;

        lp(i,6){

            sum+=a[i];

        }
        if(x==boxx && z<=boxz && z>=0 && y>=0 && y<=boxy ){

                sum-=a[6];

        }
        if(y==0 && x<=boxx && x>=0 && z>=0 && z<=boxz ){

                sum-=a[1];

        }
        if(z==boxz && x<=boxx && x>=0 && y>=0 && y<=boxy ){

                sum-=a[4];

        }
                if(x==0 && z<=boxz && z>=0 && y>=0 && y<=boxy ){

                    sum-=a[5];

        }
                if(z==0 && x<=boxx && x>=0 && y>=0 && y<=boxy ){

                    sum-=a[3];

        }
                if(y==boxy && z<=boxz && z>=0 && x>=0 && x<=boxx ){

                    sum-=a[2];

        }

        cout<<sum;
        return 0;
    }

    int sum=0;
    if(y>boxy)
        sum+=a[2];

    if(y<0)
        sum+=a[1];

    if(x>boxx)
        sum+=a[6];

    if(x<0)
        sum+=a[5];

    if(z>boxz)
        sum+=a[4];

    if(z<0)
        sum+=a[3];

    cout<<sum<<endl;

}

#include <cstdlib>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <math.h>
#include <map>
using namespace std;

#define END return 0
#define MAX 1000000007

struct Point {
public:
    int x, y, z;
};

int main() {
#ifndef ONLINE_JUDGE
    freopen("test.in", "rt", stdin);
    freopen("test.out", "wt", stdout);
#else
    //freopen("teams.in", "rt", stdin);
    //freopen("teams.out", "wt", stdout);
#endif
    Point vasya, top;
    int a[7];
    int ans = 0;
    cin >> vasya.x >> vasya.y >> vasya.z;
    cin >> top.x >> top.y >> top.z;
    for (int i = 1; i <= 6; ++i)
        cin >> a[i];
    if (vasya.z < 0)
        ans += a[3];
    if (vasya.z > top.z)
        ans += a[4];
    if (vasya.y < 0)
        ans += a[1];
    if (vasya.y > top.y)
        ans += a[2];
    if (vasya.x < 0)
        ans += a[5];
    if (vasya.x > top.x)
        ans += a[6];
    cout << ans << endl;
    return 0;
}

#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <sstream>
#include <numeric>
#include <assert.h>

using namespace std;

#define lop(i,n) for(int i=0 ;i<n ;i++)
#define VI    vector<int>
#define VLL    vector<ll>
#define VPI    vector<pair<int,int>>
#define VII    vector<VI>
#define all(v)    v.begin() , v.end()
#define SORT(v)    sort(all(v))
#define ll    long long
#define ull unsigned long long
#define scni(x)    scanf("%d",&x)
#define scnll(x)    scanf("%lld",&x)
#define scnd(x)    scanf("%lf",&x)
#define prnti(x)    printf("%d\n",x)
#define prntll(x)    printf("%lld",x)
#define prntd(x)    printf("%.9lf",x)
#define sz(x)  x.size()
#define pp push_back
#define P pair<int , int>
#define mp make_pair

const double EPS = 1e-9;
const double PI = 3.14159265359;

//  O( n * log(log(n)) )
vector<ll> primes;
void GeneratingPrimes(int top){
    vector<bool> p (top+1 , 1);
//    vector<ll> primes;
    p[0] = p[1] = 0;

    for(int i = 2; i <= sqrt(top) ; i++){
        if(p[i]){
            for(int j = i*i ; j <= top ; j+=i){
                p[j]=0;
            }
        }
    }
    lop(i , top+1)
        if(p[i])primes.push_back(i);
//    return primes;
}

ll gcd(ll a ,ll b){return (b==0)?a : gcd(b , a%b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a , b);}
void EXTgcd(ll a , ll b , ll & x0 , ll & y0){
    if(b==0){ x0 =1 , y0 = 0; return; }
    EXTgcd( b , a%b , x0 , y0 );
    ll x1 = y0;
    ll y1 = x0 - (a/b) * (y0);

	y1 = y1;
    x0 = x1;
    y0 = y1;
}

long long power(long long n, long long p , ll mod) {
    if (!p)
        return 1;
    long long ans = 1;
    while (p > 1) {
        if (p & 1)
            ans = (ans * n) % mod;
        n = (n * n) % mod;
        p /= 2;
    }
    return (ans * n) % mod;
}

double dist(double a , double b , double x, double y){ return sqrt( pow( a-x ,2) + pow( b-y ,2) ); }
double dist3(double a , double b , double c , double x , double y ,double z ){ return sqrt( pow( a-x ,2) + pow( b-y ,2) + pow( c-z ,2)); }

int xadd[9]= { 1 , -1 , 0 , 1 , -1 , 0 , 1 , -1 , 0 };
int yadd[9]= { 1 , -1 , 0 ,-1 ,  0 , 1 , 0 ,  1, -1 };

int xx[4]={0 , 1 , 0 , -1};
int yy[4]={1 , 0 , -1 , 0};

#define no  { cout<<"NO\n";  }
#define yes { cout<<"YES\n"; }
#define _1  { cout<<"-1\n";  }

ll const N = 1e3 + 10;
ll const INF = 1e18;
ll const mod = 1000000009;

///////////////////////////////////////////////////////////////////

int X,Y,Z ,x,y,z,a[7],ans;

int getx(){
	if(x<=X && x>=0)return 0;
	if(x > X)return a[6];
	return a[5];
}
int gety(){
	if(y<=Y && y>=0)return 0;
	if(y > Y)return a[2];
	return a[1];
}
int getz(){
	if(z<=Z && z>=0)return 0;
	if(z > Z)return a[4];
	return a[3];
}

int main(){
	cin >> x>>y>>z >> X >> Y >> Z;
	lop(i,6)cin>>a[i+1];

	ans = getx();
	ans += gety();
	ans += getz();
	cout << ans;
return 0;}

#include <bits/stdc++.h>

using namespace std;

#define F first

#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef string str;

str ITS(ll x)
{
	str s="";
	while (x>0)
	{
		s+=(char)(x%10+'0');
		x/=10;
	}
	str t="";
	for (int i=s.size()-1;i>-1;i--)
		t+=s[i];
	return t;
}

ll bmm(ll a,ll b)
{
	if (a==0)
		return b;
	return bmm(b%a,a);
}

bool aval(ll x)
{
	if (x<2)
		return 0;
	if (x<4)
		return 1;
	for (ll i=2;i*i<=x;i++)
		if (x%i==0)
			return 0;
	return 1;
}

ll inf=1e18;
ll mod=1e9+7;

int main()
{
	std::ios::sync_with_stdio(false);
	ll a,b,c,x,y,z,v[6];
	cin >> x >> y >> z >> a >> b >> c;
	for (ll i=0;i<6;i++)
		cin >> v[i];
	ll r=0;
	if (y>b)
		r+=v[1];
	if (y<0)
		r+=v[0];
	if (z>c)
		r+=v[3];
	if (z<0)
		r+=v[2];
	if (x>a)
		r+=v[5];
	if (x<0)
		r+=v[4];
	cout << r;
}

#include <bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vll         vector<ll>
#define all(a)      (a).begin(),(a).end()
#define lol         1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define SIZE        1000005
#define debug(x)    cerr << #x << " = " << x << endl;
#define F first
#define S second
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl        '\n'
#define deci(n) cout<<fixed<<setprecision(n);
const double pi=acos(-1.0);

using namespace std;

void MOD(ll &x)
{
	if (x >= lol) x -= lol;
	if (x < 0) x += lol;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

void solve()
{
	int x, y, z;
	int x1, y1, z1;
	cin>>x>>y>>z>>x1>>y1>>z1;
	int a[7];
	rep(i,1,7) cin>>a[i];
	int ans = 0;
	if(y<0) ans += a[1];
	else if(y>y1) ans += a[2];
	if(x<0) ans += a[5];
	else if(x>x1) ans += a[6];
	if(z<0) ans += a[3];
	else if(z>z1) ans += a[4];
	cout<<ans;

}

// Remove  debugs!!

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
	int t=1;
//	cin>>t; int i=1;
	while(t--){
		//cout<<"Case #"<<i++<<": ";
		solve();
  	  	//cout<<endl;
  	}
	return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
//#define ll long long
//#define N 100500
//int n, k;
//ll a[N];
//
//int main ()
//{
//  while(scanf("%d%d",&n,&k)!=EOF)
//  {
//      for(int i=1;i<=n;++i)
//          scanf("%d",&a[i]);
//      int ans,ans_index,l,r;
//      int s=0;
//      sort(a+1,a+1+n);
//      l=1;ans=ans_index=1;
//      for(r=2;r<=n;++r)
//      {
//          s+=(a[r]-a[r-1])*(r-l);
//          while(s>k)
//          {
//              s-=(a[r]-a[l]);
//              l++;
//          }
//          if(r-l+1>ans)
//              ans=r-l+1,ans_index=r;
//      }
//      printf("%d %d\n",ans,a[ans_index]);
//  }
//  system("pause");
//  return 0;
//}

int obj[10];
int x,y,z,a,b,c;

int main ()
{
    while(scanf("%d%d%d",&x,&y,&z)!=EOF)
    {
        scanf("%d%d%d",&a,&b,&c);
        for(int i=1;i<=6;++i)
            scanf("%d",&obj[i]);
        int ans=0;
        if(y<0)
            ans+=obj[1];
        if(y>b)
            ans+=obj[2];
        if(z<0)
            ans+=obj[3];
        if(z>c)
            ans+=obj[4];
        if(x<0)
            ans+=obj[5];
        if(x>a)
            ans+=obj[6];
        printf("%d\n",ans);
    }

    return 0;
}

/**
 *    Author:  "Ashutosh Kaushik" !!
 *    ashutoshkaushik     (CodeForces)
**/
#include<bits/stdc++.h>
using namespace std;
#define MOD 100000000
#define hell 10000000000
#define PI 3.1415926535897932384626
#define int long long int
#define fi first
#define se second
#define pq priority_queue
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define ZERO(dabba) memset(dabba,MOD,sizeof(dabba));

template<typename T> T trace2(T a,T b){cerr <<a << " " << b << endl; }
template<typename T> T trace3(T a,T b,T c){cerr <<a << " " << b <<" " << c << endl; }
template<typename T> T trace4(T a,T b,T c,T d){cerr <<a << " " << b <<" " << c <<" " << d << endl; }
template<typename T> T trace5(T a,T b,T c,T d,T e){cerr <<a << " " << b <<" " << c <<" "<<d << " "<< e <<endl; }
template<typename T> T trace6(T a,T b,T c,T d,T e,T f){cerr <<a << " " << b <<" " << c << " " << d << " "<<e << " "<< f << endl; }

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
template<typename T> T pow(T a,T b, int m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
void swap(int *a,int *b){int temp = *a;*a = *b;*b = temp;return ;}
/*******************************Template ends**************************************/
void fuck()
{
    int x,y,z,x1,y1,z1;
    cin >> x >> y >> z >> x1 >> y1 >> z1;
    int a[7];
    rep(i,1,6+1)cin >> a[i];
    int ans = 0;
    if(y < 0)
    {
        ans += a[1];
    }
    if(y > y1)
        ans+= a[2];
    if(z < 0)
        ans += a[3];
    if(z > z1)
        ans += a[4];
    if(x < 0)
        ans += a[5];
    if(x > x1)
        ans += a[6];
    cout << ans << endl;
}

signed main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fuck();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const int N = 1e5+50;
const ll oo = 1e18;
const int mod = 1e9+7;

int a[7];
int main(){
	int cx,cy,cz,x,y,z;
	cin>>cx>>cy>>cz>>x>>y>>z;
	for(int i=1;i<=6;i++)cin>>a[i];
	int sum=0;
	if(cx > x)sum+=a[6];
	if(cx < 0)sum+=a[5];
	if(cy > y)sum+=a[2];
	if(cy < 0)sum+=a[1];
	if(cz > z)sum+=a[4];
	if(cz < 0)sum+=a[3];
	cout << sum << endl;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    int x,y,z;
    int x1,y1,z1;
    int a[55];
    cin>>x>>y>>z>>x1>>y1>>z1;
    for(int i=1;i<=6;i++)
        cin>>a[i];
    int ans=0;
    if(x<0)
        x+=a[5];
    else if(x>x1)
        ans+=a[6];
    if(y<0)
        ans+=a[1];
    else if(y>y1) ans+=a[2];
    if(z<0)
        ans+=a[3];
    else if(z>z1)
        ans+=a[4];
    cout<<ans<<endl;
}

#pragma comment(linker, "/STACK:1024000000,1024000000")
//c++提交 栈空间扩充
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <sstream>
#include <cstddef>
#include <algorithm>
#include <utility>
#include <iterator>
#include <numeric>
#include <list>
#include <complex>
#include <cstdio>
#include <climits>
#include <iostream>
#include <fstream>

/*** TEMPLATE CODE STARTS HERE ***/

using namespace std;

typedef vector<int> vi;
typedef vector<string> vs;
typedef __int64 ll;
typedef complex<double> pnt;
typedef pair<int, int> pii;

#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define ls rt << 1
#define rs rt << 1 | 1

#define inf (1<<30-1)
#define eps 1e-6
#define N 105
/*** TEMPLATE CODE ENDS HERE */
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

struct Point{
	double x,y,z;
	void read(){
		cin>>x>>y>>z;
	}
	Point(){}
	Point(double xx,double yy,double zz):x(xx),y(yy),z(zz){}
	double operator*(Point p){
		return x*p.x+y*p.y+z*p.z;
	}
}a[6],jian[6];
int lx[6];
int main(){
	a[0] = Point(0,-1,0);jian[0]=Point(0,0,0);
	a[1] = Point(0,1,0);jian[1]=Point(0,1,0);
	a[2] = Point(0,0,-1);jian[2]=Point(0,0,0);
	a[3] = Point(0,0,1);jian[3]=Point(0,0,1);
	a[4] = Point(-1,0,0);jian[4]=Point(0,0,0);
	a[5] = Point(1,0,0);jian[5]=Point(1,0,0);
	Point v,b;
	v.read();
	b.read();
	for(int i=0;i<6;i++)cin>>lx[i];

	int sum=0;
	for(int i=0;i<6;i++){
		if(a[i]*Point(v.x-jian[i].x,v.y-jian[i].y,v.z-jian[i].z)>eps){
			sum +=lx[i];
		}
	}
	cout<<sum<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i,n) for(int i=0;i<n;i++)
#define foo(i,a,b) for(int i=a;i<b;i++)
#define mp make_pair
#define deb(x) cout<<#x<<"-->"<<x<<endl;
#define deb1a(v) for(auto it:v) {cout<<it<<" ";} cout<<endl;
#define deb2a(v) for(auto it:v){for(auto it1:it) {cout<<it1<<" ";}cout<<endl;}
int32_t main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int x,y,z,x1,x2,x3;
cin>>x>>y>>z>>x1>>x2>>x3;
vec v(6);
fo(i,6)
cin>>v[i];
int ans=0;
if(x>x1)
ans+=v[5];
if(x<0)
    ans+=v[4];
if(y>x2)
ans+=v[1];
if(y<0)
    ans+=v[0];
    if(z>x3)
ans+=v[3];
if(x<0)
    ans+=v[2];
    cout<<ans;

}

/*

 * This code is written by Sanskar Agarwal

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ll long long
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define VPLL vector<PLL>
#define VPII vector<PII>
#define PQ priority_queue<PLL,VPLL, greater<PLL> >
#define PQI priority_queue<PII,VPII,greater<PII> >
#define S second
#define F first
#define PB push_back

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int x,y,z,x1,y1,z1,cnt[6];
    cin>>x>>y>>z>>x1>>y1>>z1>>cnt[0]>>cnt[1]>>cnt[2]>>cnt[3]>>cnt[4]>>cnt[5];
    int a[6]={0};

    if(x==0||x==x1)
    {
        a[4]--;
        a[5]--;
    }
    else if(x<0)
    {
        a[5]--;
    }
    else if(x>x1)
    {
        a[4]--;
    }

    if(y==0||y==y1)
    {
        a[1]--;
        a[0]--;
    }
    else if(y<0)
    {
        a[1]--;
    }
    else if(y>y1)
    {
        a[0]--;
    }

    if(z==0||z==z1)
    {
        a[3]--;
        a[4]--;
    }
    else if(z<0)
    {
        a[3]--;
    }
    else if(z>z1)
    {
        a[2]--;
    }
    int sm=0;
    for(int i=0;i<6;i++)
    {
        if(a[i]==0)
            sm+=cnt[i];
    }
    cout << sm;

    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    #endif
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int a[7];
int main(){ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int x,y,z,xf,yf,zf;
cin>>x>>y>>z>>xf>>yf>>zf;
for(int i=1;i<=6;i++){
    cin>>a[i];
}
long long ans=0;
if(x<0)ans+=a[1];
if(y<0)ans+=a[5];
if(x>xf)ans+=a[6];
if(y>yf)ans+=a[2];
if(z<0)ans+=a[3];
if(z>zf)ans+=a[4];
cout<<ans;
return 0;
}

#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int x, y, z, x1, y1, z1, a, b, c, d, e, f;
    cin >> x >> y >> z >> x1 >> y1 >> z1 >> a >> b >> c >> d >> e >> f;
    if (x > x1 && y > y1 && z > z1)
        cout << b + d + f;
    else if (x <= x1 && y > y1 && z > z1)
        cout << b + d;
    else if (x <= x1 && y <= y1 && z > z1)
        cout << d;
    else if (x <= x1 && y > y1 && z <= z1)
        cout << b;

    else if (x > x1 && y <= y1 && z > z1)
        cout << f + d;
    else if (x > x1 && y <= y1 && z <= z1)
        cout << f;

    else if (x > x1 && y > y1 && z <= z1)
        cout << b + f;
}

//includes
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <utility>
#include <algorithm>
#include <cassert>

using namespace std;

//typedefs
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

//defines-general
#define to(a) __typeof(a)
#define all(vec)  vec.begin(),vec.end()
#define fill(a,val)  memset(a,val,sizeof(a))

//defines-iteration
#define repi(i,a,b) for(__typeof(b) i = a;i<b;i++)
#define repii(i,a,b) for(__typeof(b) i = a;i<=b;i++)
#define repr(i,b,a) for(__typeof(b) i = b;i>a;i--)
#define repri(i,b,a) for(__typeof(b) i = b;i>=a;i--)
#define tr(vec,it)  for(__typeof(vec.begin())  it = vec.begin();it!=vec.end();++it)

//defines-pair
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

// my own
#define sl(a) scanf("%lld",&a)
#define sll(a,b) scanf("%lld%lld",&a,&b)
#define slll(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sllll(a,b,c,d) scanf("%lld%lld%lld%lld",&a,&b,&c,&d)

ll primes[111111];
void init(){
    // cout<<"init"<<endl;
    repi(i,0,111111LL) primes[i] = 1;
    repi(i,2,111111LL){
        // cout<<"i = "<<i<<endl;
        if(primes[i]){
            for(ll j = i*i; j<=111111LL; j += i)
            {
                // cout<<"j = "<<j<<endl;
                primes[j] = 0;
            }
        }
    }
}

ll find_pf(ll a, ll st){
    vll ret;
    repi(i,st, a+1){
        if(primes[i] && (a%i==0))
            return i;
    }
    return 1;
}

int period(char* a, ll n, ll st = 2){
    ll k = find_pf(n, st);
    if(k==1) return n;
    ll p = n/k;
    bool ok = true;
    repi(i,1,k){
        repi(j,0,p){
            if(a[j] != a[p*i + j]){
                ok = false;
                break;
            }
        }
        if(!ok)
            break;
    }
    if(ok){
        return period(a, p, k);
    }
    else{
        return period(a, n, k+1);
    }
}

ll gcdd(ll a, ll b){
    if(b==0) return a;
    return gcdd(b, a%b);
}
char a[111111], b[111111];
int main(){
    init();

    cin>>a>>b;
    ll na = strlen(a);
    ll nb = strlen(b);
    ll g = gcdd(na, nb);
    ll nag = na/g;
    ll nbg = nb/g;
    bool ok = true;
    repi(i,0,g){
        char c = a[i];
        repi(j,0,nag){
            if(a[i + g*j] != c){
                // cout<<"aa"<<i<<" "<<j<<endl;
                ok = false;
                break;
            }
        }
        repi(j,0,nbg){
            if(b[i + j*g] != c){
                // cout<<"bb"<<i<<" "<<j<<endl;
                ok = false;
                break;
            }
        }
    }
    if(!ok){
        cout<<"0"<<endl;
        return 0;
    }
    ll p = period(a, g);
    ll base = g/p;
    vll tt;
    repi(i,2,111111){
        if(base%i == 0 && primes[i]){
            ll chi= 0;
            while(base%i==0){
                chi++;
                base /= i;
            }
            tt.pb(chi);
        }
    }
    assert(base==1);
    ll sz = tt.size();
    ll ans = 1;
    repi(i,0,sz){
        ans *= (tt[i]+1);
    }
    cout<<ans<<endl;
}

#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <memory.h>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <memory.h>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <complex>
#include <list>
#include <deque>
#pragma comment(linker, "/STACK:16777216") // SET_STACKSIZE_16MB
using namespace std;

typedef long long ll;

const long double PI = acos(-1.0);
const double eps = 1e-12;
const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;
const int MAXPRIMES = 2000000; // 3163 = sqrt(10^9) (FOR GENPRIMES)

int x_1,y_1,z_1,x_2,y_2,z_2,ans;
int a[6];
int main()
{
    scanf("%d%d%d",&x_1,&y_1,&z_1);
    scanf("%d%d%d",&x_2,&y_2,&z_2);
    ans = 0;
    for (int i = 0; i < 6; i++)
    {
        scanf("%d",&a[i]);
    }
    if (z_1 > 0)
    {
        ans = ans + a[3];
    }
    if (z_1 < 0)
    {
        ans = ans + a[2];
    }
    if (y_1 > 0)
    {
        ans = ans + a[1];
    }
    if (y_1 < 0)
    {
        ans = ans + a[0];
    }
    if (x_1 > 0)
    {
        ans = ans + a[5];
    }
    if (x_1 < 0)
    {
        ans = ans + a[4];
    }
    printf("%d", ans);
    return 0;
}

#include <iostream>
using namespace std;

int main() {
	int x , y , z , x1 , y1 , z1 ;
	scanf("%d %d %d %d %d %d" , &x , &y , &z  , &x1 , &y1 , &z1 );
	int a1 , a2 , a3 , a4 , a5 , a6 ;
	scanf("%d %d %d %d %d %d" , &a1 , &a2 , &a3 , &a4 , &a5 , &a6) ;
	int ans = 0 ;
	if (y > y1 && z>z1 && x>x1 )ans= a2+a6+a4 ;
	else if (y > y1 && z>z1 && x<=x1)ans = a4+a2 ;
	else if (y > y1 && z<=z1 && x>x1)ans=a2+a6 ;
	else if (y <=y1 && z>z1 && x>x1)ans = a4+a6 ;
	else if (y<= y1 && z<=z1 && x > x1)ans = a6 ;
	else if (y>y1 && z<=z1 && x<= x1)ans = a2;
	else if (y <= y1 && z>z1 && x<= x1) ans = a4 ;

	printf("%d\n" , ans) ;

	return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int xs,ys,zs,x,y,z;
int a[6];
int main()
{
  //  freopen("ulaz.txt","r",stdin);
    cin>>xs;
    cin>>ys;
    cin>>zs;
    cin>>x;
    cin>>y;
    cin>>z;
    int t;
    for(int i=1;i<7;i++){
        cin>>t;
        a[i]=t;
    }
    int zbir=0;
    if(xs<0){
        zbir+=a[5];
    }
    if(xs>x){
        zbir+=a[6];
    }
    if(ys<0){
        zbir+=a[1];
    }
    if(ys>y){
        zbir+=a[2];
    }
    if(zs<0){
        zbir+=a[3];
    }
    if(zs>y){
        zbir+=a[4];
    }
    cout<<zbir;
    return 0;
}

#pragma comment(linker, "/stack:336777216")
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = float;

ll const mod = 1000000007;

inline namespace geometry {

	ld const MIN = 0.0000000000001;
	template <typename T>
	using point3d = array<T, 3>;
	template <typename T>
	using point2d = array<T, 2>;
	template <typename T>
	using vector3d = array<T, 3>;
	template <typename T>
	using vector2d = array<T, 2>;
	template <typename T>
	using line3d = pair<point3d<T>, point3d<T>>;
	template<typename T>
	using line2d = pair<point2d<T>, point2d<T>>;
	template<typename T>
	using segment3d = pair<point3d<T>, point3d<T>>;
	template<typename T>
	using segment2d = pair<point2d<T>, point2d<T>>;
	template<typename T>
	using plane = pair<point3d<T>, vector3d<T>>;
	enum Result { Disjoint, Unique, Nonunique };

	template<typename T>
	vector3d<T> cross(vector3d<T> const &A, vector3d<T> const &B) {
		vector3d<T> ans;
		ans[0] = A[1] * B[2] - A[2] * B[1];
		ans[1] = A[2] * B[0] - A[0] * B[2];
		ans[2] = A[0] * B[1] - A[1] * B[0];
		return ans;
	}

	template<typename T>
	T perp(vector2d<T> const &A, vector2d<T> const &B) {
		return A[0] * B[1] - A[1] * B[0];
	}

	template<typename T>
	T dot(vector3d<T> const &A, vector3d<T> const &B) {
		return A[0] * B[0] + A[1] * B[1] + A[2] * B[2];
	}

	template<typename T>
	T dot(vector2d<T> const &A, vector2d<T> const &B) {
		return A[0] * B[0] + A[1] * B[1];
	}

	template<typename T, size_t size>
	array<T, size> operator+(array<T, size> const &a, array<T, size> const &b) {
		array<T, size> ans;
		for (int i = 0; i < size; i++) ans[i] = a[i] + b[i];
		return ans;
	}

	template<typename T, size_t s>
	array<T, s> operator-(array<T, s> const &a, const array<T, s> &b) {
		array<T, s> ans;
		for (int i = 0; i < ans.size(); i++) ans[i] = a[i] - b[i];
		return ans;
	}

	template<typename T, size_t s>
	array<T, s> operator*(array<T, s> const &a, ld const &b) {
		array<T, s> ans;
		for (int i = 0; i < ans.size(); i++) ans[i] = a[i] * b;
		return ans;
	}

	template<typename T>
	pair<Result, point3d<T>> SegmentPlaneIntersect3D(segment3d<T> const &seg, plane<T> const &plane) {
		vector3d<T> x = seg.second - seg.first;
		vector3d<T> y = seg.first - plane.first;
		T D = dot(plane.second, x);
		T N = -dot(plane.second, y);
		if (abs(D) < MIN) {
			if (N == 0)
				return { Nonunique,{} };
			else
				return { Disjoint,{} };
		}
		T param = N / D;
		if (param < 0 || param > 1)
			return { Disjoint,{} };
		point3d<T> ans = seg.first + (x * param);
		return { Unique,ans };
	}

	template<typename T>
	pair<Result, line3d<T>> PlanePlaneIntersect2D(plane<T> const &p1, plane<T> const &p2) {
		vector3d<T> u = cross(p1.second, p2.second);
		T ax = abs(u[0]);
		T ay = abs(u[1]);
		T az = abs(u[2]);
		if (ax + ay + az < MIN) {
			vector3d<T> check = p2.first - p1.first;
			if (dot(p1.second, check) == 0)
				return { Nonunique,{ {},{} } };
			else
				return { Disjoint,{ {},{} } };
		}
		int maxc;
		if (ax > ay) {
			if (ax > az) maxc = 1;
			else maxc = 3;
		}
		else {
			if (ay > az) maxc = 2;
			else maxc = 3;
		}
		point3d<T> intersect;
		T d1 = -dot(p1.second, p1.first);
		T d2 = -dot(p2.second, p2.first);
		switch (maxc) {
		case 1:
			intersect[0] = 0;
			intersect[1] = (d2 * p1.second[2] - d1 * p2.second[2]) / u[0];
			intersect[2] = (d1*p2.second[1] - d2 * p1.second[1]) / u[0];
			break;
		case 2:
			intersect[0] = (d1*p2.second[2] - d2 * p1.second[2]) / u[1];
			intersect[1] = 0;
			intersect[2] = (d2*p1.second[0] - d1 * p2.second[0]) / u[1];
			break;
		case 3:
			intersect[0] = (d2*p1.second[1] - d1 * p2.second[1]) / u[2];
			intersect[1] = (d1*p2.second[0] - d2 * p1.second[0]) / u[2];
			intersect[2] = 0;
		}
		point3d<T> pt0 = intersect;
		point3d<T> pt1 = intersect + u;
		return { Unique,{ pt0,pt1 } };
	}

	template<typename T>
	T PointLineDistance3D(point3d<T> &A, point3d<T> &B, point3d<T> &C) {
		point3d<T> BA, BC;
		for (int i = 0; i < 3; i++) {
			BA[i] = A[i] - B[i];
			BC[i] = C[i] - B[i];
		}
		point3d<T> BAXBC;
		BAXBC[0] = BA[1] * BC[2] - BA[2] * BC[1];
		BAXBC[1] = BA[2] * BC[0] - BA[0] * BC[2];
		BAXBC[2] = BA[0] * BC[1] - BA[1] * BC[0];
		T modUP = 0.0, modDOWN = 0.0;
		for (int i = 0; i < 3; i++) {
			modUP += BAXBC[i] * BAXBC[i];
			modDOWN += BC[i] * BC[i];
		}
		T distance = modUP / modDOWN;
		return distance;
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	ld x, y, z;
	cin >> x >> y >> z;
	ld cx, cy, cz;
	cin >> cx >> cy >> cz;
	int ans = 0;
	point3d<ld> vision = { x,y,z };
	vector<plane<ld>> planes;
	planes.push_back({ { 0,0,0 },{ 0,-1,0 } });
	planes.push_back({ { 0,cy,0 },{ 0,1,0 } });
	planes.push_back({ { 0,0,0 },{ 0,0,-1 } });
	planes.push_back({ { 0,0,cz },{ 0,0,1 } });
	planes.push_back({ { 0,0,0 },{ -1,0,0 } });
	planes.push_back({ { cx,0,0 },{ 1,0,0 } });
	vector<point3d<ld>> centers;
	centers.push_back({ cx / 2,0,cz / 2 });
	centers.push_back({ cx / 2,cy,cz / 2 });
	centers.push_back({ cx / 2,cy / 2,0 });
	centers.push_back({ cx / 2,cy / 2,cz });
	centers.push_back({ 0,cy / 2,cz / 2 });
	centers.push_back({ cx,cy / 2,cz / 2 });
	vector<point3d<ld>> bounds;
	bounds.push_back({ cx,0,cz });
	bounds.push_back({ cx,cy,cz });
	bounds.push_back({ cx,cy,0 });
	bounds.push_back({ cx,cy,cz });
	bounds.push_back({ 0,cy,cz });
	bounds.push_back({ cx,cy,cz });
	for (int i = 0; i < 6; i++) {
		int a;
		cin >> a;
		bool ok = true;
		// for all j != i check for 2nd condition
		segment3d<ld> seg = { centers[i],vision };
		for (int j = 0; j < 6; j++) {
			if (i == j) continue;
			auto res = SegmentPlaneIntersect3D(seg, planes[j]);
			if (res.first == Disjoint) continue;
			else if (res.first == Unique) {
				point3d<ld> &ip = res.second;
				if (ip[0] >= 0 && ip[0] <= bounds[j][0] && ip[1] >= 0 && ip[1] <= bounds[j][1] && ip[2] >= 0 && ip[2] <= bounds[j][2])
					ok = false;
			}
			else {
				ok = false;
			}
		}
		auto res = SegmentPlaneIntersect3D(seg, planes[i]);
		if (res.first != Unique) ok = false;
		if (ok) ans += a;
	}
	cout << ans << endl;
	return 0;
}

// In the name of God

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <complex>
#include <cmath>
#include <fstream>
#include <iomanip>
#include <ctime>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
typedef pair<int,int> pii;
typedef pair<int,pii> ppii;

int main(){
	ll X,Y,Z;
	cin>>X>>Y>>Z;
	ll x,y,z;
	cin>>x>>y>>z;
	ll a[10];
	for(int i=1; i<=6; i++)
		cin>>a[i];
	ll sum=0;
	if(X>x)
		sum+=a[2];
	if(X<0)
		sum+=a[1];
	if(Y>y)
		sum+=a[6];
	if(Y<0)
		sum+=a[5];
	if(Z>z)
		sum+=a[4];
	if(Z<0)
		sum+=a[5];
	cout<<sum<<endl;

return 0;
}

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <cstdio>

#define MAXN 12000
#define pb push_back
#define mk make_pair
#define F first
#define S second

using namespace std;

bool was[300][120000];
int a[300];
int n,l, d;
void rec(int v, int x)
{
	//cerr << v << " " << x << endl;

	if (was[v][x + MAXN]) return;
	was[v][x + MAXN] = 1;
        if (v > n)
        {
         	if (x == 0)
                {
         		for (int i = 1; i <= n; i++)
         		cout << a[i] << " ";
         		exit(0);
         	}
        }
        else
        {
           	for (int i = -2000; i <= 2000; i++)
           	if (i + x >= 1 && x + i <= l)
           	{
           	 	a[v] = x + i;
           	 	rec(v + 1, i);
           	}
        }
}

int main(){
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	cin >> n >> d >> l;

	rec(1, d);

	cout << -1;

	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<math.h>
#include<queue>
#include<stack>
#include<sstream>
#include<stdio.h>
#include<map>
#include<set>
#include<memory.h>
#include<algorithm>
#include<vector>
#include<time.h>
using namespace std;
typedef long long ll;
#define FOR(I,N) for(int i=(I);i<(N);++i)
const int N = 41;
int res, a, b, c, a1, b1, c1;
int v[6];
int main(){
	cin >> a >> b >> c;
	cin >> a1 >> b1 >> c1;
	for (int i = 0; i < 6; ++i)
		cin >> v[i];
	if (a >= a1)
		res += v[5];
	else if (a <= 0)
		res += v[4];
	if (b >= b1)
		res += v[3];
	else if (b <= 0)
		res += v[2];
	if (c >= c1)
		res += v[1];
	else if (c <= 0)
		res += v[0];
	cout << res << endl;
}

#include <bits/stdc++.h>
using namespace std;

int a[6];

int main(){
    int x,y,z,x1,y1,z1,sum=0;
    cin >> x >> y >> z >> x1 >> y1 >> z1;
    for(int i=0;i<6;i++)
        cin >> a[i];
    if(z > z1) sum+=a[3];
    else if(z < 0) sum+=a[2];
    if(y > y1) sum+=a[1];
    else if(y < 0) sum+=a[0];
    if(x > x1) sum+=a[5];
    else if(x < 0)sum+=a[6];
    cout<<sum<<endl;
}

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int nMax = 10;

int a[nMax];

int x,y,z,rx,ry,rz;

int Area(){
	if(y<0 && x>=0 && x<=rx && z>=0 && z<=rz)	return 1;
	if(y>ry && x>=0 && x<=rx && z>=0 && z<=rz)	return 2;
	if(z<0 && x>=0 && x<=rx && y>=0 && y<=ry)	return 3;
	if(z>rz && x>=0 && x<=rx && y>=0 && y<=ry)	return 4;
	if(x<0 && y>=0 && y<=ry && z>=0 && z<=rz)	return 5;
	if(x>rx && y>=0 && y<=ry && z>=0 && z<=rz)	return 6;

	if(z>=0 && z<=rz){
		if(x>rx && y>ry)	return 7;
		if(x>rx && y<0)	return 8;
		if(x<0 && y<0)		return 9;
		if(x<0 && y>ry)	return 10;
	}
	if(x>=0 && x<=rx){
		if(z<0 && y>ry)	return 11;
		if(y<0 && z<0)	return 12;
		if(y<0 && z>rz)	return 13;
		if(y>ry && z>rz)	return 14;
	}
	if(y>=0 && y<=ry){
		if(z<0 && x>rx)		return 15;
		if(z>rz && x>rx)	return 16;
		if(x<0 && z>rz)		return 17;
		if(x<0 && z<0)		return 18;
	}

	if(y<0){
		if(x<0 && z<0)	return 19;
		if(z<0 && x>rx)	return 20;
		if(x>rx && z>rz)	return 21;
		if(x<0 && z>rz)	return 22;
	}

	if(x<0 && z<0)	return 23;
	if(x>rx && z<0)	return 24;
	if(x>rx && z>rz)	return 25;
	if(x<0 && z>rz)	return 26;
}

int get_sum(int kind)
{
	if(kind>=1 && kind<=6)	return a[kind];

	if(kind==7)		return a[2]+a[6];
	if(kind==8)		return a[1]+a[6];
	if(kind==9)		return a[1]+a[5];
	if(kind==10)	return a[2]+a[5];

	if(kind==11)	return a[2]+a[3];
	if(kind==12)	return a[1]+a[3];
	if(kind==13)	return a[1]+a[4];
	if(kind==14)	return a[2]+a[4];

	if(kind==15)	return a[3]+a[6];
	if(kind==16)	return a[4]+a[6];
	if(kind==17)	return a[4]+a[5];
	if(kind==18)	return a[3]+a[5];

	if(kind==19)	return a[1]+a[3]+a[5];
	if(kind==20)	return a[1]+a[3]+a[6];
	if(kind==21)	return a[1]+a[4]+a[6];
	if(kind==22)	return a[1]+a[3]+a[4];

	if(kind==23)	return a[2]+a[3]+a[5];
	if(kind==24)	return a[2]+a[3]+a[6];
	if(kind==25)	return a[2]+a[4]+a[6];
	if(kind==26)	return a[2]+a[3]+a[4];
}

int main()
{
	scanf("%d%d%d%d%d%d",&x,&y,&z,&rx,&ry,&rz);
	for(int i=1;i<=6;i++)	scanf("%d",a+i);
	printf("%d\n",get_sum( Area() ) );
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll x,y,z,x1,y1,z1,a[6];
    ll sum=0;
    cin>>x>>y>>z;
    cin>>x1>>y1>>z1;
    for(ll i=0;i<6;i++)
        cin>>a[i];

    if(y<0)
        sum+=a[0];
    else if(y>y1)
        sum+=a[1];

    if(z<0)
        sum=a[2];
    else if(z>z1)
        sum+=a[3];

    if(x<0)
        sum+=a[4];
    else if (x>x1)
        sum+=a[5];

    cout<<sum<<endl;
    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long int
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define F first
#define S second

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<int> adj[200001];
int in[200000 + 1];
map<int, int> mp;
set<int> col[100001];
int power(int x, unsigned int y, int p)
{
  int res = 1;

  x = x % p;
  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  tc = 1;

  while (tc--)
  {
    int x, y, z, x1, y1, z1, a[6],ans=0;
    cin >> x >> y >> z;
    cin >> x1 >> y1 >> z1;
    for (int i = 0; i <6 ;i++){
      cin >> a[i];
    }
    if(x<=0){
      ans += a[0];
    }
    else if(x>=x1){
      ans += a[1];
    }
    if (y <= 0)
    {
      ans += a[2];
    }
    else if (y >= y1)
    {
      ans += a[3];
    }
    if (z <= 0)
    {
      ans += a[4];
    }
    else if (z >= z1)
    {
      ans += a[5];
    }
    cout << ans << endl;
  }
  return 0;
}

//By Lin
#include<cstdio>
#include<cstring>

using namespace std;

int     x,y,z,x1,y1,z1,a[10],ans;
bool    in_box()
{
    return x>=0 && x<=x1 && y>=0 && y<=y1 && z >=0 && z <= z1;
}
int     main()
{
    scanf("%d%d%d%d%d%d", &x, &y , &z , &x1, &y1, &z1 );
    for (int i = 1; i<=6; i++ ) scanf("%d", &a[i] );
    if ( x <  0 || in_box() ) ans += a[1];
    if ( x > x1 || in_box() ) ans += a[2];
    if ( z <  0 || in_box() ) ans += a[3];
    if ( z > z1 || in_box() ) ans += a[4];
    if ( y <  0 || in_box() ) ans += a[5];
    if ( y > y1 || in_box() ) ans += a[6];
    printf("%d\n" , ans );
    return 0;
}

#include <cstdio>
using namespace std;
/*中間の勉強したくない＞＜ it is one fifty-seven midnight*/
int a[7],x,y,z,x1,y1,z1,i,j,sum=0;
int main(){
scanf("%d%d%d%d%d%d%d%d%d%d%d%d",&x,&y,&z,&x1,&y1,&z1,&a[1],&a[2],&a[3],&a[4],&a[5],&a[6]);
if(x>x1){sum+=a[6];}
if(x<0){sum+=a[1];}
if(y>y1){sum+=a[4];}
if(y<0){sum+=a[3];}
if(z>z1){sum+=a[5];}
if(z<0){sum+=a[2];}
printf("%d\n",sum);
return 0;
}

#include <iostream>
#include <stdio.h>
#include<algorithm>
#include<math.h>
#include <iomanip>
#include <algorithm>
#include<bits/stdc++.h>
#include <iterator>
#include <cstdlib>
#include <cstdlib>
using namespace std;
void prinarray(long long int  a[],long long int  n){for(long long int  i = 0;i < n;++i){cout<<a[i]<<" ";}cout<<" "<<endl;}
void prinvector(std::vector<long long int > v){for(long long int  i = 0;i<v.size();++i){cout<<v[i]<<" ";}cout<<" "<<endl;}

void solve()
{
	int x,y,z;cin>>x>>y>>z;
    int x1,y1,z1;cin>>x1>>y1>>z1;

    int ans=0;
    int a;
    cin>>a;
    if(y1*y<0)ans+=a;
    cin>>a;
    if(y1*(y1-y)<0)ans+=a;
    cin>>a;
    if(z1*z<0)ans+=a;
    cin>>a;
    if(z1*(z1-z)<0)ans+=a;
    cin>>a;
    if(x1*x<0)ans+=a;
    cin>>a;
    if(x1*(x1-x)<0)ans+=a;
    cout<<ans<<endl;

    }

  int     main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    solve();
   return 0;
}

#include<bits/stdc++.h>
    #define ll long long
    #define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
    using namespace std;

   int main(){

            int x1,y1,z1;
            cin>>x1>>y1>>z1;
            int x,y,z;
            cin>>x>>y>>z;
            int a[6];
            for(int i=0;i<6;i++)cin>>a[i];
            if(x1<x && y1<y && z1<z){
               int ans=0;
               for(int i=0;i<6;i++)ans+=a[i];
                  cout<<ans<<endl;
                  return 0;
            }

            int ans=0;
            if(x1>x){
               ans+=a[5];
            }
            if(x1<0){
               ans+=a[4];
            }
            if(y1>y){
               ans+=a[1];
            }
            if(y1<0)ans+=a[0];

            if(z1>z){
               ans+=a[3];
            }
            if(z1<0)ans+=a[2];

            cout<<ans<<endl;

       }

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 100005;
char en = '\n';
ll inf = 1e16;
ll mod = 998244353;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

ll vector1[6][3] = {{0, -1, 0}, {0, 1, 0},  {0, 0, -1},
                    {0, 0, 1},  {-1, 0, 0}, {1, 0, 0}};
ll mul[6][3] = {{0, 1, 0}, {0, 1, 0}, {0, 0, 1},
                {0, 0, 1}, {1, 0, 0}, {1, 0, 0}};

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll x, y, z;
  ll arr2[3];
  cin >> arr2[0] >> arr2[1] >> arr2[2];
  ll x1, y1, z1;
  cin >> x1 >> y1 >> z1;

  ll arr[6];
  for (ll i = 0; i < 6; i++)
    cin >> arr[i];

  ll res = 0;
  for (ll i = 0; i < 6; i++) {

    ll num = 0;
    ll den = 0;
    for (ll j = 0; j < 3; j++) {
      num += vector1[i][j] * (mul[i][j] * arr2[j]);
      den += mul[i][j] * arr2[j];
    }
    den = abs(den);
    if (num <= 0)
      continue;
    res += arr[i];
  }
  cout << res << en;

  return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int mxn = 2e5+5;
const ll mod = 998244353;
ll a[mxn];
ll b[mxn];

int main()
{
    int n;
    cin >> n;

    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];

    for(ll i = 1; i <= n; i++) a[i] = i*(n-i+1)*a[i];
    sort(a+1, a+n+1, greater<int>());
    sort(b+1, b+n+1);
    ll ans = 0;
    for(int i = 1; i <= n; i++) ans = (ans+(a[i]%mod*b[i])%mod)%mod;
    cout << ans << '\n';
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ll;

/*
int first_pf[1000005];
bool vis [1000005];
vector<int> primes;
bool taken[1000005];

void sieve(ll n){
    memset(vis,0,sizeof vis);
    vis[0] = vis[1] = true;

    for(ll i=2; i<n;++i){
        if(vis[i])
            continue;
        for(ll j=i*i;j<n;++j){
            vis[j] = true;
            first_of[j] = i;
        }
        primes.push_back(i);
        first_pf[i] = i;
    }
}

bool test_factors(int x){
    int pf;
    while(x>1){
        pf = first_pf[x];
        int cnt =0;
        while(pf*pf <= x && x % pf == 0){
            ++cnt;
            x/= pf;
        }
        if(cnt){
            if(taken[pf]){
                memset(taken,0,sizeof taken);
                return false;
            }
            taken[pf] = true;
        }
    }

    return true;

}
*/

int main (){

    int yn, yp, zn, zp, xn ,xp , x, y, z, x1,y1,z1, ans = 0 ;
    cin >> x >> y >> z >> x1 >> y1 >> z1 >> yn >> yp >> zn >> zp >> xn >> xp;
    if(y1 > y)
        ans += yp;
    else if(y1 < 0)
        ans += yn;

    if(x1 > x)
        ans += xp;
    else if(x1 < 0)
        ans += xn;

    if(z1 > z)
        ans += zp;
    else if(z1 < 0)
        ans += zn;

    cout << ans << endl;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int person[3];
    for(int i = 0 ; i < 3 ;i++){
        cin >> person[i];
    }
    int square[3];
    for(int i = 0 ; i < 3 ;i++){
        cin >> square[i];
    }
    int faces[6];
    for(int i = 0 ;i < 6 ; i++){
        cin >> faces[i];
    }
    long sum=0;
    if(person[0]>square[0]){
        sum+=faces[5];
    }else if(person[0]<0){
    sum+=faces[4];}
    if(person[1]>square[0]){
        sum+=faces[1];
    }else if(person[1]<0){
    sum+=faces[0];}
    if(person[2]>square[2]){
        sum+=faces[3];
    }else if(person[2]<0){
    sum+=faces[2];}
    cout << sum;
    return 0;
}

//div2D
// a matter of cases
#include<bits/stdc++.h>
#define ll long long int
#define read_fast ios_base::sync_with_stdio( 0 ) , cin.tie( 0 ) , cout.tie( 0 )
using namespace std ;
bool p [ 7 ] ;
int main()
{
     read_fast ;
     int x , y , z , x1 , y1 , z1 , a [ 7 ] ;
     cin >> x >> y >> z >> x1 >> y1 >> z1 ;
     for  ( int i = 1 ; i <= 6 ; i ++ )      cin >> a [ i ] ;
     if ( abs ( z ) < z1 and abs ( x ) > x1 and abs ( z ) > 0 )
     {
          p [ 6 ] = 1 ;
          if ( abs ( z ) > z1 / 2 ) p [ 4 ] = 1 ;
          else if ( abs ( z ) > z1 / 2 ) p [ 3 ] = 1 ;
     }
     if ( abs ( z ) > z1 and abs ( x ) < x1 and abs ( x ) > 0 )
     {
          p [ 4 ] = 1 ;
          if ( abs ( x ) > x1 / 2 ) p [ 6 ] = 1 ;
          else if ( abs ( x ) < x1 / 2 ) p [ 5 ] = 1 ;
     }
     if ( abs ( z ) > z1 and abs ( x ) > x1 )  p [ 4 ] = p [ 6 ] = 1 ;
     p [ 4 ] |= ( abs ( x ) == 0 ) * 1 , p [ 6 ] |= ( abs ( z ) == 0 ) * 1 ;
     if ( y > y1 / 2   and y != y1 ) p [ 2 ] = 1 ;
     else if ( y < y1 / 2 and y != 0 ) p [ 1 ] = 1 ;
     if ( z > 0 and x < 0 )
     {
          p [ 5 ] |= ( p [ 6 ] and  1 ) ;
          p [ 6 ] =  0 ;
     }
     if ( z < 0 and x > 0 )
     {
          p [ 3 ] |= ( p [ 4 ] and  1 ) ;
          p [ 4 ] =  0 ;
     }
     ll ans = 0 ;
     if ( z < z1 and x < x1 and z >= 0 and x >= 0 )
     {
          if ( y > y1 )
               cout << p [ 2 ] ;
          else if ( y < y1 )
               cout << p [ 1 ] ;
          return 0 ;
     }
     for (  int i = 1 ; i <= 6 ; i ++  )    ans += ( p [ i ] ) * a [ i  ] ;
     cout << ans ;
     return 0 ;
}

#include        "iostream"
#include        "algorithm"
#include		"numeric"
#include        "cstring"
#include        "math.h"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        <ext/pb_ds/assoc_container.hpp> // Common file
#include        <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include        <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long
#define          pii pair<int,int>
#define          pq priority_queue
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          db(x) cout<<#x <<" : "<< x <<endl;
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update >
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("in.txt","r",stdin);
	    freopen("ou.txt","w",stdout);
	#endif
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q,x,y,z,bx,by,bz;
string s;
int vis[N],par[N],a[N];

void go()
{
	cin >> bx >> by >> bz;
	cin >> x >> y >> z;

	int ans = 0;

	fo(i,1,7) cin >> a[i];

	if( bx > x and bz > z and by > y )
	{
		ans = a[4] + a[6] + a[2];
	}
	if( bx > x and bz > z and by <= y )
	{
		ans = a[4] + a[6];
		if( by < 0 ) ans += a[1];
	}
	if( bx > x and bz <= z and by > y )
	{
		ans = a[6] + a[2];
		if( bz < 0 ) ans += a[3];
	}
	if( bx > x and bz <= z and by <= y )
	{
		ans = a[6];

		if( z < 0 and y < 0 ) ans += a[3] + a[1];
		else if( z < 0 ) ans += a[3];
		else if (y < 0 ) ans += a[1];
	}

	if( bz > z and bx <= x and by > y )
	{
		ans = a[4] + a[2];
		if (x < 0 ) ans += a[5];
	}

	if( bz > z and bx <= x and by <= y )
	{
		ans = a[4];

		if( x < 0 and y < 0 ) ans += a[5] + a[1];
		else if( x < 0 ) ans += a[5];
		else if( y < 0 ) ans += a[1];
	}

	if( by > y and bx <= x and bz <= z)
	{
		ans = a[2];

		if( x < 0 and z < 0 ) ans += a[3] + a[5];
		else if( x < 0 ) ans += a[5];
		else if( z < 0 ) ans += a[3];
	}

	if( bx <= x and by <= y and bz <= z )
	{
		if( x < 0 and y < 0 and z < 0 )
		{
			ans = a[1] + a[5] + a[3];
		}
		else if( x < 0 and z < 0 )
		{
			ans = a[3] + a[5];
		}
		else if ( x < 0 and y < 0 )
		{
			ans = a[1] + a[5];
		}
		else if( y < 0 and z < 0)
		{
			ans = a[1] + a[3];
		}
	}

	cout << ans << endl;
}

int32_t main()
{
	INP();
	FAST;
	int t=1;
	// cin>>t;
	test(t) go();
}

// amiD
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define fi first
#define ii pair<ll,ll>
#define se second
#define ld long double
#define mod 1000000007
using namespace std;
int a[11];
int main(){
    int x, y, z, X, Y, Z, ans=0;
    cin>>x>>y>>z>>X>>Y>>Z;
    for(int i=0;i<6;i++)cin>>a[i];
    if(x>0)ans+=a[1];
    else if(x<0)ans+=a[0];

    if(y>0)ans+=a[5];
    else if(y<0)ans+=a[4];

    if(z>0)ans+=a[3];
    else if(z<0)ans+=a[2];
    cout<<ans<<endl;
}

#include<bits/stdc++.h>

using namespace std;

int main(void)
{
  int x1,y1,z1;
  cin>>x1>>y1>>z1;
  int x,y,z;
  cin>>x>>y>>z;

  int arr[6];
  for(int i=0; i<6; i++)
    cin>>arr[i];
  int ans = 0;
  if(x>x1)
    ans += arr[5];
    if(x<0)
      ans += arr[4];
      if(z>z1)
        ans += arr[1];
        if(z<0)
          ans += arr[0];
          if(y>y1)
            ans+=arr[3];
            if(y<0)
              ans += arr[2];
              cout<<ans<<endl;

  return 0;
}

#include<bits/stdc++.h>

#define S(a) scanf("%d",&a)
#define P(a) printf("%d",a)
#define PS(a) printf("%s",a)

#define S2(a,b) scanf("%d%d",&a,&b)
#define S3(a,b,c) scanf("%d%d%d",&a,&b,&c)

#define SLL(a) scanf("%lld",&a)
#define PLL(a) printf("%lld",a)
#define SLL2(a,b) scanf("%lld%lld",&a,&b)
#define SLL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

#define PCASE printf("Case %d: ",kk++)
#define PCASENL printf("Case %d:\n",kk++)
#define NL puts("")

//topcoder
#define sz(a) ((int)a.size())
#define repv(i,a) for(int i=0;i<sz(a);i++)
#define revv(i,a) for(int i=sz(a)-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,a,b) for(int i=a;i>=b;i--)
#define countbit(x) __builtin_popcount(x)
#define SET(a) memset(a,-1,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define all(a) a.begin(),a.end()
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N) FOR(I,0,N)
#define rall(a) a.rbegin(),a.rend()
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pi (2.0*acos(0.0))
#define PI (2.0*acos(0.0))

#define set0(ar) memset(ar,0,sizeof ar)
#define setinf(ar) memset(ar,126,sizeof ar)
#define in(a,x,y) (a>=x && a<=y)
#define out(a,x,y) (!in(a,x,y))
#define eq(a,b) (fabs(a-b)<eps)
#define less(a,b) (a+eps<b)
#define great(a,b) (a>b+eps)
#define xx first
#define yy second
//#define root 1

#define MAX(a) (*max_element(all(a)))
#define MIN(a) (*min_element(all(a)))

#define LB(a,x) (lower_bound(all(a),x)-a.begin())
#define UB(a,x) (upper_bound(all(a),x)-a.begin())

using namespace std;
int ts,kk=1;

typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector< pii > vii;

template< class T > inline T _sq(T a) { return a * a; }
template< class T, class X > inline T _pow(T a,X y) {T z=1; rep(i,1,y){z*=a;} return z; }
template< class T > inline T _gcd(T a,T b) {a=_abs(a);b=_abs(b); if(!b) return a; return _gcd(b,a%b);}
template< class T > inline T _lcm(T a,T b) {a=_abs(a);b=_abs(b); return (a/_gcd(a,b))*b;}

template< class T > inline T _extended(T a,T b,T &x,T &y) {a=_abs(a);b=_abs(b); T g,x1,y1; if(!b) {x=1;y=0;g=a; return g;} g=_extended(b,a%b,x1,y1); x=y1; y=x1-(a/b)*y1; return g;}

template< class T, class X > inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0); }
template< class T, class X > inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template< class T, class X > inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i))); }
template< class T, class X > inline T togglebit(T a, X i) { T t=1;return (a^(t<<i)); }
//
template< class T,class X, class Y > inline T _bigmod(T n,X m,Y mod){ull ret=1, a = n%mod ; while(m){ if(m&1)ret=(ret*a)%mod; m>>=1; a=(a*a)%mod; }ret%=mod;return (T)ret;}
template< class T, class Y > inline T _modinv(T n,Y mod) {return _bigmod(n,mod-2,mod);}

/// //CONSTANT// ///
/// power 0123456789 ///
#define lmt 110
#define MX (lmt + 20 )
#define ten 10000000000LL
#define MOD 100000007
#define inf 1000000000000000000LL

#define LOGMX 30
#define eps 1e-6
///===========================///

int x,y,z,xp,yp,zp,sum;

int main()
{
    cin>>xp>>yp>>zp;
    cin>>x>>y>>z;

    int a[10];
    rep(i,1,6){
        cin>>a[i];
    }

    sum = 0;

    if(abs(yp)>abs(y) && y*yp>0) sum += a[2];
    if(y*yp<0)                   sum += a[1];

    if(abs(xp)>abs(x) && xp*x > 0 ) sum += a[6];
    if(x*xp<0)                      sum += a[5];

    if(abs(zp)>abs(z) && z*zp>0 ) sum += a[4];
    if(z*zp<0)                    sum += a[3];

    cout<<sum<<endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define ll long long
#define ld long double
#define fo(i,v,e) for(v=i;v<e;v++)
#define rfo(i,v,e) for(v=i;v>e;v--)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vl vector<ll>
#define sz(x) (int)x.size()
#define ull unsigned long long
#define vvi vector<vi>
#define vvl vector<vl>
#define vpi vector<pii>
#define vpl vector<pll>
ll mod = 1000000007;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define openfile freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#define fastio
#else
#define openfile
#define deb(x...)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#endif
void init()
{

}
void solve()
{
    ll x,y,z,xc,yc,zc,i,j,ans = 0;
    cin>>x>>y>>z;
    cin>>xc>>yc>>zc;
    vl arr(6);
    deb(xc,yc,zc)
    fo(0,i,6)
    {
        cin>>arr[i];
    }
    if(yc<0)
    {
        ans+=arr[0];
    }
    if(yc<y)
    {
        ans+=arr[1];
    }
    if(z<0)
    {
        ans+=arr[2];
    }
    if(zc<z)
    {
        ans+=arr[3];
    }
    if(x<0)
    {
        ans+=arr[4];
    }
    if(xc<x)
    {
        ans+=arr[5];
    }
    cout<<ans<<endl;
}
int main()
{
    init();
    openfile;fastio;
    int T = 1;
    // cin>>T;
    while(T--)
    {
        solve();
    }
}

#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i,n) for(int i=0;i<n;i++)
#define foo(i,a,b) for(int i=a;i<b;i++)
#define mp make_pair
#define deb(x) cout<<#x<<"-->"<<x<<endl;
#define deb1a(v) for(auto it:v) {cout<<it<<" ";} cout<<endl;
#define deb2a(v) for(auto it:v){for(auto it1:it) {cout<<it1<<" ";}cout<<endl;}
int32_t main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
int x,y,z,x1,x2,x3;
cin>>x>>y>>z>>x1>>x2>>x3;
vec v(6);
fo(i,6)
cin>>v[i];
int ans=0;
if(x>x1)
ans+=v[5];
if(x<0)
    ans+=v[4];
if(y>x2)
ans+=v[1];
if(y<0)
    ans+=v[0];
    if(z>x3)
ans+=v[3];
if(x<0)
    ans+=v[2];
    cout<<ans;

}

/*-------------icalFikr's template v2.1--------------*/

#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <algorithm>
#include <iomanip>
#include <cstddef>
#include <cassert>
#include <cctype>
#include <utility>
#include <ctime>

#ifndef GEDEBUG
	#define DEBUG printf(__VA_ARGS__)
	#define DEBUGS puts("gukguk")
	#define TIME() printf("\nFinished in %.3lf s\n",clock()/(double)CLOCKS_PER_SEC)
#else
	#define DEBUG
	#define DEBUGS
	#define TIME()
#endif

#ifdef __WIN32__
	char getchar_unlocked() { return getchar(); }
#endif

/* Abbreviations */
#define puf push_front
#define pof pop_front()
#define pub push_back
#define pob pop_back()
#define fs first
#define sc second
#define mp make_pair
#define FOR(i,a,b) for(int i=int(a),_b=int(b);i<=_b;i++)
#define FORINC(i,a,b,inc) for(int i=int(a),_b=int(b);i<=_b;i+=inc)
#define FORLL(i,a,b) for(LL i=LL(a),_b=LL(b);i<=_b;i++)
#define FORD(i,a,b) for(int i=int(a),_b=int(b);i>=_b;i--)
#define FOREACH(i,a) for (__typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define OPEN freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define CLOSE fclose(stdin); fclose(stdout);
#define ALL(v) (v).begin(),(v).end()
#define sz size()
#define reset(x,N) memset(x,N,sizeof(x))
#define nl puts("")
#define gc getchar_unlocked()

using namespace std;
typedef double db;
typedef long long LL;
typedef pair <int,int> ii;
typedef pair <LL,LL> pll;
typedef vector <ii> vii;
typedef vector <int> vint;

const db EPS	= 0.0000001;
const db PI 	= acos(-1);
const LL INFLL	= 0x7FFFFFFFFFFFFFFF;
const int INF	= 0x7FFFFFFF;

template<typename T>
inline void next(T &num) {
    char c; num=0;
    do { c=gc; }
    while (c!=EOF && c==' ' && c=='\n' && c=='\t');
    int sign=(c=='-' ? -1 : 1);
    if (c!='-') num+=(c-'0');
    while ( (c=gc)!=EOF && c!='\n' && c!='\t' && c!=' ') {
        num*=10; num+=(c-'0');
    }
    num*=sign;
}

inline string getstr() {
    string str; char k;
    while( (k=gc)==' ' || k=='\n' ) {
        k=gc;
        if ( k==' ' || k=='\n' ) continue;
        else break;
    }
	str.pub(k);
    while((k=gc)!=EOF &&k!='\n' && k!='\t'
        && k!='\v' && k!='\0' && k!=' ')
        str.pub(k);
    return str;
}

/*-------------end of template-------------*/
int x,y,z,xx,yy,zz,a,b,c;

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);

	cin >> xx >> yy >> zz;
	cin >> x >> y >> z;
	cin >> a >> a >> b >> b >> c >> c;

	int ans = 0;
	if (xx > x) ans += c;
	if (yy > y) ans += a;
	if (zz > z) ans += b;
	cout << ans;
	return 0;
}

#include<iostream>
#include<algorithm>
#include<sstream>
#include<string>
#include<cmath>
#include<vector>
#include<cstdio>

using namespace std;
int main()
{
    int x1,y1,z1,x,z,y,a1,a2,a3,a4,a5,a6;
    cin >> x>>y>>z>>x1>>y1>>z1>>a1>>a2>>a3>>a4>>a5>>a6;
    int sum=0;
    if(x > x1 && y > y1 && z>z1) sum = sum + a2 + a4 + a6;
    else if(x >= x1 && y < y1 && z<z1) sum = sum + a6;
    else if(x < x1 && y >= y1 && z<z1) sum = sum + a2;
    else if(x < x1 && y < y1 && z>=z1) sum = sum + a4;
    else if(x >= x1 && y >= y1 && z<z1) sum = sum + a2 + a6;
    else if(x >= x1 && y < y1 && z>=z1) sum = sum + a4 + a6;
    else if(x < x1 && y >= y1 && z>=z1) sum = sum + a2 + a4;
    cout << sum << endl;

//  system("pause");
    return 0;

}

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
   // ifstream cin("standard input");
    //ofstream cout("standard output");
    int x,y,z,x1,y1,z1,a1,a2,a3,a4,a5,a6,k=0;
    cin>>x>>y>>z;
    cin>>x1>>y1>>z1;
    cin>>a1>>a2>>a3>>a4>>a5>>a6;

    if(y>y1)
    k=k+a2;
    else if(y<0)
    k=k+a1;

    if(z>z1)
    k=k+a4;
    else if(y<0)
    k=k+a3;

    if(x>x1)
    k=k+a6;
    else if(x<0)
    k=k+a5;

    cout<<k<<endl;
   // cin.close();
  //  cout.close();
    return 0;
}

/// author: .24
#include<bits/stdc++.h>

using namespace std;

//#define int long long

#define fi first
#define se second

#define next nxt
#define y1 qwstebri

#define mp make_pair
#define pb push_back

#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)(x.size()))
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef unsigned long long ull;

typedef vector <int> vi;
typedef pair <int, int> pii;

const char nl = '\n';
const int mod = 1000000007;
const double pi = 4*atan(1);

const int inf = 2000000000;
const ll linf = (ll) 1e18;

const int pr = 37;
const int maxn = 100001;
const int maxn_big = 1000001;

int f[10];

main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0); srand (time (NULL));
	#ifdef mit
		freopen(".in","r",stdin);
		//freopen(".out", "w", stdout);
	#endif
	int a, b, c, x, y, z;
	cin >> a >> b >> c;
	cin >> x >> y >> z;
	int res = 0;
	for (int i = 1; i <= 6; ++ i) cin >> f[i];
	if (a > 0) res += f[5];
	if (b > 0) res += f[1];
	if (c > 0) res += f[3];
	if (a < x) res += f[6];
	if (b < y) res += f[2];
	if (c < z) res += f[4];
	cout << res;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

int main() {
	int x, y, z, q, w, e;
	cin >> x >> y >> z >> q >> w >> e;
	int a[6];
	for(int i=0;i<6;i++) cin >> a[i];
	int ans = 0;
	if(z > 0) ans += a[3];
	if(z < 0) ans += a[2];
	if(y > 0) ans += a[1];
	if(y < 0) ans += a[0];
	if(x > 0) ans += a[5];
	if(x < 0) ans += a[4];
	cout << ans;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    int x,y,z;
    int x1,y1,z1;
    int a[55];
    cin>>x>>y>>z>>x1>>y1>>z1;
    for(int i=1;i<=6;i++)
        cin>>a[i];
    int ans=0;
    if(x<0)
        x+=a[5];
     if(x>x1)
        ans+=a[6];
    if(y<0)
        ans+=a[1];
     if(y>y1)
        ans+=a[2];
    if(z<0)
        ans+=a[3];
     if(z>z1)
        ans+=a[4];
    cout<<ans<<endl;
}

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
struct ob {int64_t val; int64_t pos;};
	int64_t n,m,i,j,gd,needed,remain,a,b,c,d,x,y,fail, last,po=0, countt=0,counts=0,page,removed=0,temp,op=0,fina[500001],used[500001];
	long double r,xx,yy,dist,aa,bb,cc,dd;
vector <int64_t> bui(int64_t x)
{
	vector <int64_t> ii,jj;
	if (x>=2) {ii=bui(x/2); jj=ii; ii.push_back(x%2); ii.insert(ii.end(),jj.begin(),jj.end());} else {ii.push_back(x);}
	return ii;
}
int main()
{ 	cin>>aa>>bb>>cc;
	cin>>a>>b>>c;
	cin>>a>>b>>c>>d>>x>>y;
	if (bb>0) po+=b;
	if (bb<0) po+=a;
	if (cc>0) po+=d;
	if (cc<0) po+=c;
	if (aa>0) po+=y;
	if (aa<0) po+=x;
	cout<<po;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
using namespace std;
#define INF 0x73737373
#define EPS 1e-8
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
int main()
{
    int x, y, z;
    int a, b, c;
    int a1, a2, a3, a4, a5, a6;
    scanf("%d%d%d", &x, &y, &z);
    scanf("%d%d%d", &a, &b, &c);
    scanf("%d%d%d%d%d%d", &a1, &a2, &a3, &a4, &a5, &a6);
    int sum = 0;
    if(x - a > 0) sum += a2;
    if(x < 0) sum += a1;
    if(y - b > 0) sum += a6;
    if(y < 0) sum += a5;
    if(z - c > 0) sum += a4;
    if(z < 0) sum += a3;
    printf("%d\n", sum);
    return 0;
}

#include <iostream>
#include <vector>
using namespace std;

typedef vector<double> vi;

vi sub(vi a, vi b)
{
    vi temp;
    temp.push_back(a[0]-b[0]);
    temp.push_back(a[1]-b[1]);
    temp.push_back(a[2]-b[2]);
    return temp;
}

int dot(vi a, vi b)
{
    return a[0]*b[0]+a[1]*b[1]+a[2]*b[2];
}

vi cross(vi a,vi b)
{
    vi temp;
    temp.push_back(a[1]*b[2] - a[2]*b[1]);
    temp.push_back(a[2]*b[0] - a[0]*b[2]);
    temp.push_back(a[0]*b[1] - a[1]*b[0]);
    return temp;
}

vi mid(vi a,vi b)
{
    vi temp;
    temp.push_back((a[0]+b[0])/2);
    temp.push_back((a[1]+b[1])/2);
    temp.push_back((a[2]+b[2])/2);
    return temp;
}
void print(vi n)
{
    cout << n[0] << " " << n[1] << " " << n[2] << endl;
}
int see(vi a,vi b, vi c,vi d,int val)
{
    vi f = sub(b,a);
    vi s = sub(c,a);
    vi n = cross(f,s);
    //print(n);
    //print(sub( d , mid(b,c)));
    double v = dot(n,sub( d , mid(b,c) ));
    //cout << v << endl;
    int ret;
    if(v<=0) ret = 0;
    else ret =  val;
    //cout << ret << endl;
    return ret;
}

int main() {
    int x,y,z;
    int x1,y1,z1;
    int a[6];

    cin >> x1 >> y1 >> z1;
    cin >> x >> y >> z;

    for(int i=0;i<6;i++)
        cin >> a[i];

    vi p = vi{x1,y1,z1};
    vector< vi > b;

    b.push_back(vi{0,0,0});//0
    b.push_back(vi{0,0,z});//1
    b.push_back(vi{0,y,0});//2
    b.push_back(vi{0,y,z});//3
    b.push_back(vi{x,0,0});//4
    b.push_back(vi{x,0,z});//5
    b.push_back(vi{x,y,0});//6
    b.push_back(vi{x,y,z});//7

    int ans = 0;
    ans+=see(b[0],b[2],b[4],p,a[2]);//xoy
    ans+=see(b[0],b[1],b[2],p,a[4]);//yoz
    ans+=see(b[0],b[4],b[1],p,a[0]);//zox

    ans+=see(b[7],b[3],b[5],p,a[3]);//xoyp
    ans+=see(b[7],b[5],b[6],p,a[5]);//zoyp
    ans+=see(b[7],b[6],b[3],p,a[1]);//xozp

    cout << ans << endl;
    return 0;
}

#include <iostream>

using namespace std;

int main()
{
	int x, y, z;
	cin >>x >> y>> z;
	int x1,y1,z1;
	cin >> x1 >> y1 >> z1;
	int a[6];
	for(int i = 0; i < 6; i++)
		cin >> a[i];

	int sum = 0;
	if( x<0 )
		if(y<0)
			if(z<0)
				sum = a[0]+a[2]+a[4];
			else if(z<=z1)
				sum = a[0]+a[4];
			else
				sum = a[0]+a[4]+a[3];
		else if(y <= y1)
			if(z<0)
				sum = a[2]+a[4];
			else if(z<=z1)
				sum = a[4];
			else
				sum = a[4]+a[3];
		else
			if(z<0)
				sum = a[1]+a[2]+a[4];
			else if(x<=z1)
				sum = a[1]+a[4];
			else
				sum = a[1]+a[3]+a[4];
	else if(x<=x1)
		if(y<0)
			if(z<0)
				sum = a[0]+a[2];
			else if(z<=z1)
				sum = a[0];
			else
				sum = a[0]+a[3];
		else if(y <= y1)
			if(z<0)
				sum = a[2];
			else
				sum = a[3];
		else
			if(z<0)
				sum = a[1]+a[2];
			else if(x<=z1)
				sum = a[1];
			else
				sum = a[1]+a[3];
	else
		if(y<0)
			if(z<0)
				sum = a[0]+a[2]+a[5];
			else if(z<=z1)
				sum = a[0]+a[5];
			else
				sum = a[0]+a[5]+a[3];
		else if(y <= y1)
			if(z<0)
				sum = a[2]+a[5];
			else if(z<=z1)
				sum = a[5];
			else
				sum = a[5]+a[3];
		else
			if(z<0)
				sum = a[1]+a[2]+a[5];
			else if(x<=z1)
				sum = a[1]+a[5];
			else
				sum = a[1]+a[3]+a[5];

	cout << sum << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define mod 1000000007
#define  F first
#define  S second
#define mp make_pair
#define pb push_back
#define fast_io std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef long long int  ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <long long int, long long int> pll;
const int inf = INT_MAX;
const long long int infl = LLONG_MAX;

int main(){
	fast_io;
	ll x,y,z,x1,y1,z1;
	ll a[6];
	cin>>x>>y>>z>>x1>>y1>>z1;
	for(int i=0;i<6;i++){
		cin>>a[i];
	}
	ll ans=0;
	if(x<0){
		ans+=a[4];
	}
	if(x>x1){
		ans+=a[5];
	}
	if(y<0){
		ans+=a[0];
	}
	if(y>y1){
		ans+=a[1];
	}
	if(z<0){
		ans+=a[2];
	}
	else{
		ans+=a[3];
	}
	cout<<ans<<endl;
	return 0;
}

#include<iostream>
using namespace std;
int main()
{
	long long x,y,z;
	cin >> x >> y >> z;
	long long a,b,c;
	cin >> a >> b >> c;
	long long a1,a2,a3,a4,a5,a6;
	cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6;
	if(x > a)
	{
		if(y > b)
		{
			if(z > c)
			{
				cout << a2 + a4 + a6<< endl;;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a2 + a6<< endl;
			}
			else
			{
				cout << a2 + a3 + a6 << endl;
			}
		}
		else if(y >= 0 && y <= b)
		{
			if(z > c)
			{
				cout <<  a4 + a6;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a6 << endl;
			}
			else
			{
				cout << a6 + a3 << endl;
			}
		}
		else
		{
			if(z > c)
			{
				cout << a4 + a6 + a1 << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a6 + a1 << endl;
			}
			else
			{
				cout << a6 + a1 + a3 << endl;
			}
		}
	}
	else if(x >= 0 && x <= a)
	{
		if(y > b)
		{
			if(z > c)
			{
				cout << a4 + a2 << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a2 << endl;
			}
			else
			{
				cout << a2 + a1 << endl;
			}
		}
		if(y >= 0 && y <= b)
		{
			if(z > c)
			{
				cout << a4 << endl;
			}
			else
			{
				cout << a4 << endl;
			}
		}
		else
		{
			if(z > c)
			{
				cout << a4 + a1 << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a1 << endl;
			}
			else
			{
				cout << a1 + a3 << endl;
			}
		}
	}
	else
	{
		if(y > b)
		{
			if(z > c)
			{
				cout << a5 + a4 + a2 << endl;
			}
			if(z >= 0 && z <= c)
			{
				cout << a5 + a2 << endl;
			}
			else
			{
				cout << a5 + a2 + a3 << endl;
			}
		}
		else if(y >= 0 && y <= b)
		{
			if(z > c)
			{
				cout << a5 + a4 <<endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a5 << endl;
			}
			else
			{
				cout << a5 + a1 << endl;
			}
		}
		else
		{
			if(z > c)
			{
				cout << a5 + a1 + a4  << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a5 + a1 << endl;
			}
			else
			{
				cout << a5 + a1 + a4 << endl;
			}
		}
	}
}

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcount
#define sqr(x) ((x) * (x))
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ull inf = (ull)4e18 + 1;

const double pi = acos(-1.0);       																																																																									// Ya katala
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int x, y, z, x1, y1, z1, a[7], ans;

inline void boost () {
	ios_base :: sync_with_stdio (NULL);
	cin.tie (NULL), cout.tie (NULL);
}

inline void Solve () {
	cin >> x >> y >> z >> x1 >> y1 >> z1;
	for (int i = 1; i <= 6; i ++) cin >> a[i];
	if (x < 0) ans += a[1];
	if (x > x1) ans += a[2];
	if (y < 0) ans += a[3];
	if (y > y1) ans += a[4];
	if (z < 0) ans += a[5];
	if (z > z1) ans += a[6];
	cout << ans;
}

main () {
//	freopen ("gcm.in", "r", stdin);
//	freopen ("gcm.out", "w", stdout);
	boost ();
	int tt = 1;
//	cin >> tt;
	while (tt --) {
		Solve ();
	}
	return 0;
}

//By Lin
#include<cstdio>
#include<cstring>

using namespace std;

int     x,y,z,x1,y1,z1,a[10],ans;
bool    in_box()
{
    return x>=0 && x<=x1 && y>=0 && y<=y1 && z >=0 && z <= z1;
}
int     main()
{
    scanf("%d%d%d%d%d%d", &x, &y , &z , &x1, &y1, &z1 );
    for (int i = 1; i<=6; i++ ) scanf("%d", &a[i] );
    if ( x <  0 || in_box() ) ans += a[1];
    if ( x > x1 || in_box() ) ans += a[2];
    if ( z <  0 || in_box() ) ans += a[3];
    if ( z > z1 || in_box() ) ans += a[4];
    if ( y <  0 || in_box() ) ans += a[5];
    if ( y > y1 || in_box() ) ans += a[6];
    printf("%d\n" , ans );
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int x,y,z,X1,Y1,Z1,a[7];
int main()
{
    cin>>x>>y>>z>>X1>>Y1>>Z1;
    for(int i=1;i<=6;i++)cin>>a[i];
    long long ans=0;
    if(x>X1)ans+=a[2];
    else if(x<0)ans+=a[1];

    if(y>Y1)ans+=a[6];
    else if(y<0)ans+=a[5];

    if(z>Z1)ans+=a[4];
    else if(z<0)ans+=a[3];
    cout<<ans;
}

#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cassert>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#pragma comment(linker, "/STACK:250000000")
template<typename T> int size(T& a){ return (int) a.size(); }
template<typename T> T sqr(T a){ return a * a; }

#define _(a, b) memset((a), (b), sizeof(a))
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(), a.end()
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define REPD(i, a, b) for(int i = (b) - 1; i >= a; --i)

struct pt {
	ll x, y, z;
	pt (ll x, ll y, ll z) : x(x), y(y), z(z) {}
};

ll det(ll a, ll b, ll c, ll d) {
	return a*d - b*c;
}

ll gcd(ll a, ll b) {
	if (a<0) a = -a;
	if (b<0) b = -b;
	while (a&&b)
		if (a>=b)a%=b;
		else b%=a;
	return a+b;
}
struct Plane {
	ll A,B,C,D;
	Plane(){}
	int val;
	Plane(pt a, pt b, pt c, int val) {
		A=det(b.y-a.y, b.z-a.z, c.y-a.y, c.z-a.z);
		B=-det(b.x-a.x, b.z-a.z, c.x-a.x, c.z - a.z);
		C=det(b.x-a.x, b.y-a.y, c.x-a.x, c.y-a.y);
		D=-A*a.x-B*a.y-C*a.z;
		this->val=val;
		norm();
	}
	void norm() {
		ll g = gcd(A, gcd(B, gcd(C, D)));
		if (g != 0)
			A/=g, B/=g,C/=g, D/=g;
		if (A<0 || A==0 && B<0 || A==0 && B==0 && C<0 || A==0 && B==0 && C==0 && D<0)
			A=-A,B=-B,C=-C,D=-D;
	}
};

Plane p[3][2];
int a[6];
int main() {
#ifdef air
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

	ll x, y, z;
	ll x1, y1, z1;
	cin >> x >> y >> z;
	cin >> x1 >> y1 >> z1;
	REP(i, 0, 6) cin >> a[i];
	p[0][0] = Plane(pt(0, 0, 0), pt(0, 0, z1), pt(x1, 0, 0), a[0]);
	p[0][1] = Plane(pt(0, y1, 0), pt(0, y1, z1), pt(x1, y1, 0), a[1]);
	p[1][0] = Plane(pt(0, 0, 0), pt(x1, 0, 0), pt(0, y1, 0), a[2]);
	p[1][1] = Plane(pt(0, 0, z1), pt(0, y1, z1), pt(x1, 0, z1), a[3]);
	p[2][0] = Plane(pt(0, 0, 0), pt(0, y1, 0), pt(0, 0, z1), a[4]);
	p[2][1] = Plane(pt(x1, 0, 0), pt(x1, 0, z1), pt(x1, y1, z1), a[5]);

	int ans=0;
	REP(it, 0, 3) {
		ll d1 = p[it][0].A * x + p[it][0].B * y + p[it][0].C * z + p[it][0].D;
		ll d2 = p[it][1].A * x + p[it][1].B * y + p[it][1].C * z + p[it][1].D;
		if (d1==0 || d2==0) continue;
		if (!((d1>0) ^ (d2>0))) {
			if (d1<0) d1=-d2,d2=-d2;
			ll b1 = sqr(p[it][0].A) + sqr(p[it][0].B) + sqr(p[it][0].C);
			ll b2 = sqr(p[it][1].A) + sqr(p[it][1].B) + sqr(p[it][1].C);
			if (d1*d1*b2 < b1*d2*d2) ans += p[it][0].val;
			else ans += p[it][1].val;
		}
	}
	cout << ans;

#ifdef air
    printf("\n\n%.2lf\n", clock() * 1e-3);
#endif
}

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx")
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mp make_pair
#define REPP(i,l,r,c) for (int i=l;i<r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define REPS(i,l,r) REP(i,l,r+1)
#define FOR(i,n) REP(i,0,n)
#define REPD(i,l,r) for (int i=r-1;i>=l;i--)
#define FORD(i,n) REPD(i,0,n)
#define FOREACH(i,n) for (auto i:n)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

const int INF=(int)1E9;
const ll INFLL=(ll)1E15;
const ll MOD=(ll)1E9+7;
const double PI=acos(-1);
const double EPS=1E-9;

bool between(int x,int l,int r) {
	return (l<=x && x<=r);
}

string tostring(int x) {
	char dum[20]; sprintf(dum,"%d",x);
	string ret(dum); return ret;
}

void in(int &number) {
    bool negative=false; register int c; number=0;
    c=getchar();
    if (c=='-') negative=true, c=getchar();
    for (;c>47&&c<58;c=getchar()) number=number*10+c-48;
    if (negative) number*=-1;
}

int x,y,z,x1,y1,z1,a1,a2,a3,a4,a5,a6;

int main() {
	cin>>x>>y>>z>>x1>>y1>>y1>>a1>>a2>>a3>>a4>>a5>>a6;
	int ans=0;
	if (y<0) ans+=a1;
	if (y>y1) ans+=a2;
	if (z<0) ans+=a3;
	if (z>z1) ans+=a4;
	if (x<0) ans+=a5;
	if (x>x1) ans+=a6;
	cout<<ans<<endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define SZ(A) int(A.size())
#define LN(A) int(strlen(A))

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
const double EPS = 1e-5;
const int MOD = int(1e8), MX = int(3e4);

int x, y, z, a, b, c, A[6], sum;

int inside() {
  int f = x > 0 && y > 0 && z > 0 && x < a && b < y && c < z;
  if(f) printf("%d\n", sum);
  return f;
}

void onedge() {
  int f = 0;
  if(y == b || !y) sum -= A[0] + A[1], f = 1;
  if(z == c || !z) sum -= A[2] + A[3], f = 1;
  if(x == a || !x) sum -= A[4] + A[5], f = 1;
}

void outside() {
  if(x < 0) sum -= A[5];
  if(x > a) sum -= A[4];
  if(y < 0) sum -= A[1];
  if(y > b) sum -= A[0];
  if(z < 0) sum -= A[3];
  if(z > c) sum -= A[2];
  printf("%d\n", sum);
}

void solve() {
  scanf("%d %d %d", &x, &y, &z);
  scanf("%d %d %d", &a, &b, &c);
  for(int i = 0; i < 6; i++) scanf("%d", &A[i]), sum += A[i];
  if(inside()) return;
  onedge();
  outside();
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("../in.txt", "r", stdin);
#endif
  solve();
}

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

int a[10];

void solve() {
    int x, y, z;
    cin >> x >> y >> z;

    int x1, y1, z1;
    cin >> x1 >> y1 >> z1;

    int ans = 0;
    for (int i = 1; i <= 6; i++)cin >> a[i];
    if (x >= x1)ans += a[6];
    if (y >= y1)ans += a[2];
    if (z >= z1)ans += a[4];
    if (x < 0)ans += a[5];
    if (y < 0)ans += a[1];
    if (z < 0)ans += a[3];
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    pair < pair <int,int>, int > vasya,cubic;
    int arr[6],sum=0;
    scanf("%d%d%d",&vasya.first.first,&vasya.first.second,&vasya.second);
    scanf("%d%d%d",&cubic.first.first,&cubic.first.second,&cubic.second);
    for (int i=0; i<6; i++)
        scanf("%d",&arr[i]);
    if(vasya.first.second<0)
        sum+=arr[0];
    if(vasya.first.second>0&&cubic.first.second!=vasya.first.second)
        sum+=arr[1];
    if(vasya.second<0)
        sum+=arr[2];
    if(vasya.second>0&&cubic.second!=vasya.second)
        sum+=arr[3];
    if(vasya.first.first<0)
        sum+=arr[4];
    if(vasya.first.first>0&&cubic.first.first!=vasya.first.first)
        sum+=arr[5];
    printf("%d",sum);
}

#include<iostream>
using namespace std;
int main()
{
	long long x,y,z;
	cin >> x >> y >> z;
	long long a,b,c;
	cin >> a >> b >> c;
	long long a1,a2,a3,a4,a5,a6;
	cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6;
	if(x > a)
	{
		if(y > b)
		{
			if(z > c)
			{
				cout << a2 + a4 + a6<< endl;;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a2 + a6<< endl;
			}
			else
			{
				cout << a2 + a3 + a6 << endl;
			}
		}
		else if(y >= 0 && y <= b)
		{
			if(z > c)
			{
				cout <<  a4 + a6;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a6 << endl;
			}
			else
			{
				cout << a6 + a3 << endl;
			}
		}
		else
		{
			if(z > c)
			{
				cout << a4 + a6 + a1 << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a6 + a1 << endl;
			}
			else
			{
				cout << a6 + a1 + a3 << endl;
			}
		}
	}
	else if(x >= 0 && x <= a)
	{
		if(y > b)
		{
			if(z > c)
			{
				cout << a4 + a2 << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a2 << endl;
			}
			else
			{
				cout << a2 + a1 << endl;
			}
		}
		if(y >= 0 && y <= b)
		{
			if(z > c)
			{
				cout << a4 << endl;
			}
			else
			{
				cout << a4 << endl;
			}
		}
		else
		{
			if(z > c)
			{
				cout << a4 + a1 << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a1 << endl;
			}
			else
			{
				cout << a1 + a3 << endl;
			}
		}
	}
	else
	{
		if(y > b)
		{
			if(z > c)
			{
				cout << a5 + a4 + a2 << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a5 + a2 << endl;
			}
			else
			{
				cout << a5 + a2 + a3 << endl;
			}
		}
		else if(y >= 0 && y <= b)
		{
			if(z > c)
			{
				cout << a5 + a4 <<endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a5 << endl;
			}
			else
			{
				cout << a5 + a1 << endl;
			}
		}
		else
		{
			if(z > c)
			{
				cout << a5 + a1 + a4  << endl;
			}
			else if(z >= 0 && z <= c)
			{
				cout << a5 + a1 << endl;
			}
			else
			{
				cout << a5 + a1 + a4 << endl;
			}
		}
	}
}

/****** BISMILLAH HIR RAHMANIR RAHIM ******/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;

typedef long long ll;
typedef unsigned int ul;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef map<string,string> mss;
typedef map<int, vector<int> > mvii;
typedef map<int, int> mii;
typedef queue <int> qi;
typedef map <int, vector<string> > mvis;
typedef map <string, vector<int> > mvsi;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef vector<pair<int,int> > vpii;

// Order Statistic Tree

/* Special functions:

		find_by_order(k) --> returns iterator to the kth largest element counting from 0
		order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/

// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

#define MP make_pair
#define SORT(a) sort (a.begin(), a.end())
#define REVERSE(a) reverse (a.begin(), a.end())
#define ALL(a) a.begin(), a.end()
#define PI acos(-1)
#define ms(x,y) memset (x, y, sizeof (x))
#define INF 2000000000
#define pb push_back
#define MAX 100002
#define debug cout<<"A"<<"\n"
#define prnt(a) cout<<a<<"\n"
#define mod 1000000007LL
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORr(i,a,b) for (int i=(a); i>=b; i--)
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define lc ((node)<<1)
#define rc ((node)<<1|1)
#define VecPrnt(v) FOR(J,0,v.size()) cout<<v[J]<<" "; cout<<endl
#define endl "\n"
#define PrintPair(x) cout<<x.first<<" "<<x.second<<endl
#define ClearQ(x); while(!x.empty()) x.pop()
#define EPS 1e-9
#define ArrPrint(a,st,en) for(int J=st; J<=en; J++) cout<<a[J]<<" "; cout<<endl;

/* Direction Array */

// int fx[]={1,-1,0,0};
// int fy[]={0,0,1,-1};
// int fx[]={0,0,1,-1,-1,1,-1,1};
// int fy[]={-1,1,0,0,1,1,-1,-1};

template <class T> inline T bigmod(T p,T e,T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}

template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}

inline ll getnum()
{
    char c = getchar();
    ll num,sign=1;
    for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;
    for(num=0;c>='0'&&c<='9';)
    {
        c-='0';
        num = num*10+c;
        c=getchar();
    }
    return num*sign;
}

inline ll power(ll a, ll b)
{
	ll multiply=1;
	FOR(i,0,b)
	{
		multiply*=a;
	}
	return multiply;
}

/****** END OF HEADER ******/

int x1, x2, yy1, y2, z1, z2;
int a[7], x, y, z;
int ans=0;

bool check()
{
	if(x1>=0 && x1<=x && yy1>=0 && yy1<=y && z1>=0 && z1<=z)
		return true;

	return false;
}

int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL); cout.tie(NULL);
    // freopen("in.txt","r",stdin);

    int test, cases=1;

    cin>>x1>>yy1>>z1;
    cin>>x>>y>>z;
    FOR(i,1,7) cin>>a[i];

    if(check())
    {
    	prnt(0);
    	return 0;
    }

    if(z1>z)
    {
    	ans=a[4];

    	if(yy1>y) ans+=a[2];
    	else if(yy1<0) ans+=a[1];
    	if(x1>x) ans+=a[6];
    	else if(x1<0) ans+=a[5];
    }
    else if(z1<0)
    {
    	ans=a[3];

    	if(yy1>y) ans+=a[2];
    	else if(yy1<0) ans+=a[1];
    	if(x1>x) ans+=a[6];
    	else if(x1<0) ans+=a[5];
    }
    else if(x1>x)
    {
    	ans=a[6];

    	if(yy1>y) ans+=a[2];
    	else if(yy1<0) ans+=a[1];
    }
    else if(x1<0)
    {
    	ans=a[5];

    	if(yy1>y) ans+=a[2];
    	else if(yy1<0) ans+=a[1];
    }

    prnt(ans);

    return 0;
}

#include<bits/stdc++.h>
#define lld long long int
#define vll vector<lld>
#define pll pair<lld,lld>
#define mll map<lld,lld>
#define sll set<lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 500005
#define lld_max 5000000000000000000
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define REP(i,a,b) for(i=a;i<=b;i++)
#define rREP(i,a,b) for(i=a;i>=b;i--)
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        cin>>x>>y>>z;
        lld a,b,c; cin>>a>>b>>c;
        lld dp[6]; REP(i,0,5) cin>>dp[i]; vll v;
        if(x>0) v.pb(dp[5]); else v.pb(dp[4]);
        if(y>0) v.pb(dp[1]); else v.pb(dp[0]);
        if(z>0) v.pb(dp[3]); else v.pb(dp[2]);
        if(abs(x)>a) cnt+=v[0];
        if(abs(y)>b) cnt+=v[1];
        if(abs(z)>c) cnt+=v[2];
        op(cnt);
    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/

/*

 * This code is written by Sanskar Agarwal

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ll long long
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define VPLL vector<PLL>
#define VPII vector<PII>
#define PQ priority_queue<PLL,VPLL, greater<PLL> >
#define PQI priority_queue<PII,VPII,greater<PII> >
#define S second
#define F first
#define PB push_back

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int x,y,z,x1,y1,z1,cnt[6];
    cin>>x>>y>>z>>x1>>y1>>z1>>cnt[0]>>cnt[1]>>cnt[2]>>cnt[3]>>cnt[4]>>cnt[5];
    int a[6]={0};

    if(x==0||x==x1)
    {
        a[4]--;
        a[5]--;
    }
    else if(x<0)
    {
        a[5]--;
    }
    else if(x>x1)
    {
        a[4]--;
    }

    if(y==0||y==y1)
    {
        a[1]--;
        a[0]--;
    }
    else if(y<0)
    {
        a[1]--;
    }
    else if(y>y1)
    {
        a[0]--;
    }

    if(z==0||z==z1)
    {
        a[3]--;
        a[2]--;
    }
    else if(z<0)
    {
        a[3]--;
    }
    else if(z>z1)
    {
        a[2]--;
    }
    int sm=0;
    for(int i=0;i<6;i++)
    {
        if(a[i]==0)
            sm+=cnt[i];
    }
    cout << sm;

    #ifndef ONLINE_JUDGE
        cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s\n";
    #endif
    return 0;
}

/**
 *    Author:  "Ashutosh Kaushik" !!
 *    ashutoshkaushik     (CodeForces)
**/
#include<bits/stdc++.h>
using namespace std;
#define MOD 100000000
#define hell 10000000000
#define PI 3.1415926535897932384626
#define int long long int
#define fi first
#define se second
#define pq priority_queue
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define ZERO(dabba) memset(dabba,MOD,sizeof(dabba));

template<typename T> T trace2(T a,T b){cerr <<a << " " << b << endl; }
template<typename T> T trace3(T a,T b,T c){cerr <<a << " " << b <<" " << c << endl; }
template<typename T> T trace4(T a,T b,T c,T d){cerr <<a << " " << b <<" " << c <<" " << d << endl; }
template<typename T> T trace5(T a,T b,T c,T d,T e){cerr <<a << " " << b <<" " << c <<" "<<d << " "<< e <<endl; }
template<typename T> T trace6(T a,T b,T c,T d,T e,T f){cerr <<a << " " << b <<" " << c << " " << d << " "<<e << " "<< f << endl; }

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
template<typename T> T pow(T a,T b, int m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
void swap(int *a,int *b){int temp = *a;*a = *b;*b = temp;return ;}
/*******************************Template ends**************************************/
void fuck()
{
    int x,y,z,x1,y1,z1;
    cin >> x >> y >> z >> x1 >> y1 >> z1;
    int a[7];
    rep(i,1,6+1)cin >> a[i];
    int ans = 0;
    if(y < 0)
    {
        ans += a[1];
    }
    if(y > y1)
        ans+= a[2];
    if(z < 0)
        ans += a[3];
    if(z > z1)
        ans += a[4];
    if(y < 0)
        ans += a[5];
    if(y > y1)
        ans += a[6];
    cout << ans << endl;
}

signed main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fuck();
    return 0;
}

#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf 9e18
#define mod 1000000007
#define mod1 998244353
long long int power(long long int a,long long int n,long long int m) ;
long long int power(long long int a,long long int n,long long int m)
{  if(n==0)
   return 1 ;
   long long int x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
map<ll,ll>::iterator it ;

int main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,o,temp;
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   ll x1,x2,x3,x4,x5,x6 ;
   cin>>x>>y>>z ;
   cin>>a>>b>>c ;
   cin>>x1>>x2>>x3>>x4>>x5>>x6 ;
   cnt=0 ;
   if(y>=b)
    cnt+=x2 ;
   else if(y<=-1*b)
    cnt+=x1 ;
   if(z>=c)
    cnt+=x4 ;
   else if(z<=-1*c)
    cnt+=x3 ;
    if(x>=a)
    cnt+=x6 ;
   else if(x<=-a)
    cnt+=x5 ;
   cout<<cnt<<"\n" ;
   return 0; }

#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
ll mod = 1e9+7;

struct xyz {
    ll x,y,z;
};
int main()
{
    ll x,y,z,x1,y1,z1,i;
    vector<xyz> face(7);
    vector<ll> val(7);
    cin>>x>>y>>z;
    cin>>x1>>y1>>z1;
    for(i=1;i<=6;i++)
    {
        face[i].x = 0;
        face[i].y = 0;
        face[i].z = 0;
        cin>>val[i];
    }
    face[1].y = -1;
    face[2].y = 1;
    face[3].z = -1;
    face[4].z = 1;
    face[5].x = -1;
    face[6].x = 1;

    ll sum = 0;
    for(i=1;i<=6;i++)
    {
        if(x*face[i].x + y*face[i].y + z*face[i].z > 0)
        {
            sum+=val[i];
        }
    }

    cout<<sum<<"\n";
}

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;

#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcount
#define sqr(x) ((x) * (x))
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos(-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

bool used[123];
int pref[1501], k, h[1501], pw[1501], p = 313;
string s, x;
set <int> ans;

inline int mult (int a, int b) {
	return 1ll * a * b % mod;
}

inline int add (int a, int b) {
	a += b;
	if (a < mod) a += mod;
	if (a >= mod) a -= mod;
	return a;
}

inline int hh (int l, int r) {
	return add (h[r], mult(-h[l - 1], pw[r - l + 1]));
}

inline void boost () {
	ios_base :: sync_with_stdio (NULL);
	cin.tie (NULL), cout.tie (NULL);
}

inline void Solve () {
	cin >> s >> x >> k;
	int n = sz (s);
	pw[0] = 1;
	for (int i = 1; i <= n; i ++) pw[i] = mult (pw[i - 1], p);
	s = '#' + s;
	for (int i = 1; i <= n; i ++) {
		pref[i] = pref[i - 1] + (x[s[i] - 'a'] == '0');
		h[i] = add (mult (h[i - 1], p), s[i]);
	}
	for (int len = 1; len <= n; len ++) {
		for (int i = 1; i + len - 1 <= n; i ++) {
			if (pref[i + len - 1] - pref[i - 1] <= k) {
				ans.in (hh (i, i + len - 1));
			}
		}
	}
	cout << sz (ans);
}

main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int tt = 1;
//	cin >> tt;
	while (tt --) {
		Solve ();
	}
	return 0;
}

#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <cctype>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

#define fast() { ios_base::sync_with_stdio (0); cin.tie (0); cout.tie (0); }
#define PER(i, a, b) for(int i = a - 1; i >= (b); i--)
#define REP(i, a, b) for(int i = a; i < (b); i++)
#define FILL(a, b) memset((a), b, sizeof(a))
#define INF (1L << 60)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI acos(-1.0)
#define SQR(a) (a)*(a)
#define int64 long long
#define PII pair<int, int>
#define VI vector<int>

int main ()
{
	int x1, y1, z1, x, y, z, a1, a2, a3, a4, a5, a6, sum;
	cin >> x >> y >> z;
	cin >> x1 >> y1 >> z1 >> a1 >> a2 >> a3 >> a4 >> a5 >> a6;
	if (y1 > 0) {
		if (y > y1) sum += a2;
		else if (y < 0) sum += a1;
	} else {
		if (y > 0) sum += a2;
		else if (y < y1) sum += a1;
	}
	if (z1 > 0) {
		if (z > z1) sum += a4;
		else if (z < 0) sum += a3;
	} else {
		if (z > 0) sum += a4;
		else if (y < y1) sum += a3;
	}
	if (x1 > 0) {
		if (x > x1) sum += a6;
		else if (x < 0) sum += a5;
	} else {
		if (x > 0) sum += a6;
		else if (x < x1) sum += a5;
	}
	cout << sum << endl;
	return 0;
}

//////////////                AAYUSH SINGH NARUKA                         \\\\\\\\\\\\\\\\\\

//////////////                     AA18                        \\\\\\\\\\\\\\\\\\

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define front(i,x,n) for( i=x;i<n;i++)
#define back(i,x,n) for( i=x;i>=0;i--)
#define all(x) x.begin(),x.end()
#define mp(x,y) make_pair(x,y)
#define mod 1000000007
#define pr(x) printf("%lld",x)
#define sc(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define end printf("\n")
#define space printf(" ")
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test cin>>t;while(t--)

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll power(ll x, ll y, ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;

    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(ll a, ll m)
{
    ll g = gcd(a, m);
    if (g != 1)
        return 0;
    else
    {
        ll p=power(a, m-2, m);
        return p;
    }
}

int main()
{
    jaldi
	ll t,n,i,j,c,s=0,m,q,k,p;
    ll arr[5];
    ll view[3];
    ll given[3];
    for(i=0;i<3;i++)
      cin>>view[i];
      for(i=0;i<3;i++)
      cin>>given[i];
      for(i=0;i<6;i++)
        cin>>arr[i];
    if(view[0]<0)
      s = s + arr[4];
    if(view[1]<0)
      s = s + arr[0];
      if(view[2]<0)
      s = s + arr[2];
      if(view[0]>=given[0])
         s = s + arr[5];
         if(view[1]>=given[1])
         s = s + arr[1];
         if(view[2]>=given[2])
         s = s + arr[3];
         cout<<s<<endl;

	return 0;
}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
using namespace std;
#define INF 0x73737373
#define EPS 1e-8
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
int main()
{
    int x, y, z;
    int a, b, c;
    int a1, a2, a3, a4, a5, a6;
    scanf("%d%d%d", &x, &y, &z);
    scanf("%d%d%d", &a, &b, &c);
    scanf("%d%d%d%d%d%d", &a1, &a2, &a3, &a4, &a5, &a6);
    int sum = 0;
    if(x - a > 0) sum += a2;
    if(x < 0) sum += a1;
    if(y - b > 0) sum += a6;
    if(y < 0) sum += a5;
    if(z - c > 0) sum += a4;
    if(z < 0) sum += a5;
    if(x - a <= 0 && y - b <= 0 && z - c <= 0)
        sum = a1 + a2 + a3 + a4 + a5 + a6;
    if(x - a <= 0 && y - b <= 0)
        if(z - c > 0) sum = a4;
        else sum = a3;
    if(y - b <= 0 && z - c <= 0)
        if(x - a > 0) sum = a6;
        else sum = a5;
    if(x - a <= 0 && z - c <= 0)
        if(y - b > 0) sum = a2;
        else sum = a1;
    printf("%d\n", sum);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int a[6];

int main(){
    int x,y,z,x1,y1,z1,sum=0;
    cin >> x >> y >> z >> x1 >> y1 >> z1;
    for(int i=0;i<6;i++)
        cin >> a[i];
    if(z > z1) sum+=a[3];
    else if(z < 0) sum+=a[2];
    if(y > y1) sum+=a[1];
    else if(y < 0) sum+=a[0];
    if(x > x1) sum+=a[5];
    else if(x < 0)sum+=a[6];
    cout<<sum<<endl;
}

#include <bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vll         vector<ll>
#define all(a)      (a).begin(),(a).end()
#define lol         1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define SIZE        1000005
#define debug(x)    cerr << #x << " = " << x << endl;
#define F first
#define S second
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
#define endl        '\n'
#define deci(n) cout<<fixed<<setprecision(n);
const double pi=acos(-1.0);

using namespace std;

void MOD(ll &x)
{
	if (x >= lol) x -= lol;
	if (x < 0) x += lol;
}

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

void solve()
{
	int x, y, z;
	int x1, y1, z1;
	cin>>x>>y>>z>>x1>>y1>>z1;
	int a[7];
	rep(i,1,7) cin>>a[i];
	int ans = 0;
	if(y<0) ans += a[1];
	else if(y>0) ans += a[2];
	if(x<0) ans += a[5];
	else if(x>0) ans += a[6];
	if(z<0) ans += a[3];
	else if(z>0) ans += a[4];
	cout<<ans;

}

// Remove  debugs!!

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
	int t=1;
//	cin>>t; int i=1;
	while(t--){
		//cout<<"Case #"<<i++<<": ";
		solve();
  	  	//cout<<endl;
  	}
	return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front;
#define fbo find_by_order
#define ook order_of_key
#define lb lower_bound
#define ub upper_bound
#define rep(i,n) for(int i=0;i<n;i++)
#define fo(j,a,b) for(int j=a;j<=b;j++)
#define mem(x,a) memset(x,a,sizeof(x))

typedef long long ll;
typedef double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef map<ll,ll> spt;
typedef set<ll> si;
typedef multiset<ll>::iterator sit;
typedef map<int,int>::iterator mi;
typedef vector<int>::iterator vit;
typedef vector<ii> vii;
typedef set<ii> sii;
typedef multiset<ll> msi;
typedef vector< vector<ll> > matrix;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ost1;
template<class T> T chmin(T& a, T& b) { if(a>b) return a; }
template<class T> T chmax(T& a, T& b) { if(a<b) return b; }
const ll INF = 1e18;
const int MOD = 1e8;
const int N = 1e6 + 5  ;
ll modpow(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int main()
{
    ll x1,y1,z1,x,y,z;
    cin>>x>>y>>z>>x1>>y1>>z1;
    ll a[6];
    rep(i,6)
    cin>>a[i];
    ll ans;
    ans=a[0]*(y<0)+a[1]*(y>y1)+a[2]*(z<0)+a[3]*(z>z1)+a[4]*(x<0)+a[5]*(x>x1);
}

#include<bits/stdc++.h>
#include<string>
#define rep(i,a,b) for(long long int i=(a);i<(b);i++)
#define se(a) a.begin(),a.end()
#define ll long long int
#define mll map<ll,ll>
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define mk make_pair
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e16
#define boost ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
int main()
{
	boost;
	ll x,y,z;
	cin>>x>>y>>z;
	ll x1,y1,z1;
	cin>>x1>>y1>>z1;
	ll a1,a2,a3,a4,a5,a6;
	cin>>a1>>a2>>a3>>a4>>a5>>a6;
	if(x<0||y<0||z<0)
	{
		x=abs(x);y=abs(y);z=abs(z);
		if(x>x1&&y>y1&&z>z1)
		{cout<<a1+a3+a5;return 0;}
		if((x<=x1&&y<=y1&&z<=z1))
		{cout<<0;return 0;}
		if(x>x1&y>y1&&z<=z1)
		{cout<<a1+a5;return 0;}
		if(x>x1&&z>z1&&y<=y1)
		{cout<<a3+a5;return 0;}
		if(z>z1&&y>y1&&x<=x1)
		{cout<<a1+a3;return 0;}
		if(x>x1&&y<=y1&&z<=z1)
		{cout<<a5;return 0;}
		if(x<=x1&&y>y1&&z<=z1)
		{cout<<a1;return 0;}
		if(x<=x1&&y<=y1&&z>z1)
		{cout<<a3;return 0;}
	}
	if(x>x1&&y>y1&&z>z1)
	{cout<<a2+a4+a6;return 0;}
	if((x<=x1&&y<=y1&&z<=z1))
	{cout<<0;return 0;}
	if(x>x1&y>y1&&z<=z1)
	{cout<<a2+a6;return 0;}
	if(x>x1&&z>z1&&y<=y1)
	{cout<<a4+a6;return 0;}
	if(z>z1&&y>y1&&x<=x1)
	{cout<<a2+a4;return 0;}
	if(x>x1&&y<=y1&&z<=z1)
	{cout<<a6;return 0;}
	if(x<=x1&&y>y1&&z<=z1)
	{cout<<a2;return 0;}
	if(x<=x1&&y<=y1&&z>z1)
	{cout<<a4;return 0;}
}

#include <stdio.h>
#include <memory.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <utility>

using namespace std;

int main()
{
    int x,y,z;
    int bx,by,bz;
    vector<int> wtf(7);
    cin >> x >> y >> z;
    cin >> bx >> by >> bz;
    for(int i=1;i<=6;i++)
        cin >> wtf[i];
    int c[7]={0,};
    if( y < 0 ) c[1]=1;
    else if( y > by ) c[2]=1;
    if( z < 0 ) c[3]=1;
    else if( z > by ) c[4]=1;
    if( x < 0  ) c[5]=1;
    else if( x > bx ) c[6]=1;
    int res=0;
    for(int i=1;i<=6;i++)
        res+=c[i]*wtf[i];
    cout << res << endl;
    return 0;
}

/// author: .24
#include<bits/stdc++.h>

using namespace std;

//#define int long long

#define fi first
#define se second

#define next nxt
#define y1 qwstebri

#define mp make_pair
#define pb push_back

#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)(x.size()))
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef unsigned long long ull;

typedef vector <int> vi;
typedef pair <int, int> pii;

const char nl = '\n';
const int mod = 1000000007;
const double pi = 4*atan(1);

const int inf = 2000000000;
const ll linf = (ll) 1e18;

const int pr = 37;
const int maxn = 100001;
const int maxn_big = 1000001;

int f[10];

main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0); srand (time (NULL));
	#ifdef mit
		freopen(".in","r",stdin);
		//freopen(".out", "w", stdout);
	#endif
	int a, b, c, x, y, z;
	cin >> a >> b >> c;
	cin >> x >> y >> z;
	int res = 0;
	for (int i = 1; i <= 6; ++ i) cin >> f[i];
	if (a > 0) res += f[2];
	if (b > 0) res += f[6];
	if (c > 0) res += f[4];
	if (a < x) res += f[1];
	if (b < y) res += f[5];
	if (c < z) res += f[3];
	cout << res;
	return 0;
}

#include<algorithm>
#include<sstream>
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<map>

using namespace std;

int main() {
   // freopen("inp.txt", "r", stdin);
    int x, y, z;
    int x1, y1, z1;
    int sum = 0;
    cin >> x >> y >> z;
    cin >> x1 >> y1 >> z1;
    int a[6];
    for (int i = 0; i < 6; i++) {
        cin >> a[i];
        sum += a[i];
    }
    if(x == y && x == z && x ==0){
        cout << 0 << endl;
    }
    else if (x == y && x ==0){
        cout << a[3] << endl;
    }else if(x == z && x ==0){
        cout << a[1] << endl;
    }else if(y == z && y ==0){
        cout << a[5] << endl;
    } else{
        if (x <= 0)
            sum -= a[5];
        if (x >= x1)
            sum -= a[4];
        if (y <= 0)
            sum -= a[1];
        if (y >= y1)
            sum -= a[0];
        if (z <= 0)
            sum -= a[3];
        if (z >= z1)
            sum -= a[2];
        cout << sum << endl;
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

int32_t main()
{
	IOS;
	int x, y, z;
	cin>>x>>y>>z;
	int x1, y1, z1;
	cin>>x1>>y1>>z1;
	int a1, a2, a3, a4, a5, a6;
	cin>>a1>>a2>>a3>>a4>>a5>>a6;
	int ans=0;
	if(x>x1)
		ans+=a6;
	else if(x<0)
		ans+=a5;
	if(y>y1)
		ans+=a2;
	else if(y<0)
		ans+=a1;
	if(z>z1)
		ans+=a4;
	else
		ans+=a3;
	cout<<ans;
	return 0;
}

// saihemanth9019
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define foi(i,a,n) for(i = (a); i <= (n); i++)
#define pd(x) cout<<x
#define sd(x) cin>>x
#define nl cout<<endl
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0)
#define gcd __gcd
#define clr(x) memset(x,0,sizeof(x))
#define all(a) (a).begin(), (a).end()
#define foreach(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//ll fibonacci[2][2] = {{0,1},{1,1}};
//ll identity[2][2] = {{1,0},{0,1}};

int main() {
	ll i,j,k;
	ll x,y,z;
	cin>>x>>y>>z;
	ll x1,y1,z1;
	cin>>x1>>y1>>z1;
	ll a1, a2, a3, a4, a5, a6;
	cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6;
	ll ans = 0;
	if(y < 0) ans += a1;
	if(y > 0) ans += a2;
	if(z < 0) ans += a3;
	if(z > 0) ans += a4;
	if(y < 0) ans += a5;
	if(y > 0) ans += a6;
	cout << ans << endl;
	return 0;
}

#include <iostream>

using namespace std;

int main()
{
    int x,y,z,x1,y1,z1,a,b,c,d,e,f;
    cin>>x>>y>>z;
    cin>>x1>>y1>>z1;
    cin>>a>>b>>c>>d>>e>>f;
    if (x<0){if (y<0){ if (z<0){cout<<a+c+e<<endl;}
                       else if ((z>=0)&&(z<=z1)){cout<<a+e<<endl;}
                       else{cout<<a+d+e<<endl;}}
             else if ((y>=0)&&(y<=y1)){if (z<0){cout<<c+e<<endl;}
                                       else if ((z>=0)&&(z<=z1)){cout<<e<<endl;}
                                       else{cout<<d+e<<endl;}}
            else {if (z<0){cout<<b+c+e<<endl;}
                  else if ((z>=0)&&(z<=z1)) {cout<<b+e<<endl;}
                  else {cout<<b+d+e<<endl;}
                 }
             }
    if ((x>=0)&&(x<=x1)){if (y<0){ if (z<0){cout<<a+c<<endl;}
                       else if ((z>=0)&&(z<=z1)){cout<<a<<endl;}
                       else{cout<<a+d<<endl;}}
             else if ((y>=0)&&(y<=y1)){if (z<0){cout<<c<<endl;}
                                       else if ((z>=0)&&(z<=z1)){}
                                       else{cout<<d<<endl;}}
            else {if (z<0){cout<<b+c<<endl;}
                  else if ((z>=0)&&(z<=z1)) {cout<<b<<endl;}
                  else {cout<<b+d<<endl;}
                 }
             }
    else {if (y<0){ if (z<0){cout<<a+c+f<<endl;}
                       else if ((z>=0)&&(z<=z1)){cout<<a+f<<endl;}
                       else{cout<<a+d+f<<endl;}}
             else if ((y>=0)&&(y<=y1)){if (z<0){cout<<c+f<<endl;}
                                       else if ((z>=0)&&(z<=z1)){cout<<f<<endl;}
                                       else{cout<<d+f<<endl;}}
            else {if (z<0){cout<<b+c+f<<endl;}
                  else if ((z>=0)&&(z<=z1)) {cout<<b+f<<endl;}
                  else {cout<<b+d+f<<endl;}
                 }
             }

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define all(c) (c).begin(),(c).end()
#define sz( s ) int( s.size() )
#define pb push_back
#define mp make_pair
#define hell 1000000007
#define F first
#define S second
ll t = 1 ;
ll dist( vector<ll> v1 , vector<ll> v2 )
{
    ll ans = 0 ;
    rep( i , 0 , 3 )
        ans += (v1[i]-v2[i])*(v1[i]-v2[i]) ;
    return ans ;
}
void solve()
{
    ll x , y , z , x1 , y1 , z1 ;
    vector<ll> a(7);
    cin >> x >> y >> z >> x1 >> y1 >> z1 ;
    rep( i , 1 , 7 )
        cin >> a[i] ;
    vector<vector<ll> > v ;
    map< vector<ll> , vector<ll> > mapa ;
    map< ll , vector< vector<ll> > > mapa1 ;
    mapa[ { 0 , 0 , 0 } ] = { 1 , 3 , 5 } ;
    mapa[ { x1 , 0 , 0 } ] = { 1 , 3 , 6 } ;
    mapa[ { x1 , y1 , 0 } ] = { 2 , 3 , 6 } ;
    mapa[ { 0 , y1 , 0 } ] = { 2 , 3 , 5 } ;
    mapa[ { 0 , 0 , z1 } ] = { 1 , 4 , 5 } ;
    mapa[ { x1 , 0 , z1 } ] = { 1 , 4 , 6 } ;
    mapa[ { x1 , y1 , z1 } ] = { 2 , 4 , 6 } ;
    mapa[ { 0 , y1 , z1 } ] = { 2 , 4 , 5 } ;
    v.pb( { 0 , 0 , 0 } ) ;
    v.pb( { x1 , 0 , 0 } ) ;
    v.pb( { x1 , y1 , 0 } ) ;
    v.pb( { 0 , y1 , 0 } ) ;
    v.pb( { 0 , 0 , z1 } ) ;
    v.pb( { x1 , 0 , z1 } ) ;
    v.pb( { x1 , y1 , z1 } ) ;
    v.pb( { 0 , y1 , z1 } ) ;
    map<ll,ll> ans ;
    rep( i , 0 , 8 )
        mapa1[dist(v[i],{x,y,z})].pb( v[i] ) ;
    ll f = 0 ;
    if( x < 0 || x > x1 )
        f++;
    if( y < 0 || y > y1 )
        f++;
    if( z < 0 || z > z1 )
        f++;
    ll xx = 0 , xx1 ;
    if( f == 1 )
        xx1 = 4 ;
    if( f == 2 )
        xx1 = 6 ;
    if( f == 3 )
        xx1 = 7 ;
    for( auto it : mapa1 )
    {
        for( auto itt : it.S )
        {
            for( auto it1 : mapa[itt] )
                ans[it1]++;
            xx++;
            if( xx >= xx1 )
            break;
        }
        if( xx >= xx1 )
            break;
    }
    ll val = 0 ;
    for( auto const& it2 : ans )
        if( it2.S >= 4 )
            val += a[it2.S] ;
    cout << val ;

}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0) ;
    cout.tie(0) ;
   // cin>>t;
    while(t--)
        solve() ;
    return 0 ;
}

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<int> VI;

int x,y,z;
int x1,yy1,z1;
int d,u,b,f,l,r;
int main()
{
	cin>>x>>y>>z>>x1>>yy1>>z1>>d>>u>>b>>f>>l>>r;
	int ans = 0;

	if(x > x1)
		ans += r;
	else if(x < 0)
		ans += l;

	if(y > yy1)
		ans += u;
	else if(x < 0)
		ans += d;

	if(z > z1)
		ans += f;
	else if(z < 0)
		ans += b;

	cout<<ans<<"\n";
	return 0;

}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int long long int
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define F first
#define S second

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<int> adj[200001];
int in[200000 + 1];
map<int, int> mp;
set<int> col[100001];
int power(int x, unsigned int y, int p)
{
  int res = 1;

  x = x % p;
  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  tc = 1;

  while (tc--)
  {
    int x, y, z, x1, y1, z1, a[6],ans=0;
    cin >> x >> y >> z;
    cin >> x1 >> y1 >> z1;
    for (int i = 0; i <6 ;i++){
      cin >> a[i];
    }
    if(x<=0){
      ans += a[0];
    }
    else if(x>=x1){
      ans += a[1];
    }
    if (y <= 0)
    {
      ans += a[2];
    }
    else if (y >= y1)
    {
      ans += a[3];
    }
    if (z <= 0)
    {
      ans += a[4];
    }
    else if (z >= z1)
    {
      ans += a[5];
    }
    cout << ans << endl;
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
//#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e10;
const int N=1e5+5;
int gcd(int n,int m)
{
    if(n==0)
        return m;
    else
        return gcd(m%n,n);
}
int power(int a,int b,int m)
{
    int ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%m;
        b/=2;
        a=(a*a)%m;
    }
    return ans;
}
int32_t main()
{
    IOS;
    int x,y,z,x1,y1,z1;
    cin>>x1>>y1>>z1;
    cin>>x>>y>>z;
    int sum=0;
    int a[8];
    for(int i=1;i<=6;i++)
    {
        cin>>a[i];
    }
    if(x1<0)
    {
        sum+=a[1];
    }
    else if(x1>x)
    {
        sum+=a[2];
    }
    if(y1<0)
    {
        sum+=a[3];
    }
    else if(y1>y)
    {
        sum+=a[4];
    }
    if(z1<0)
    {
        sum+=a[5];
    }
    else if(z1>z)
    {
        sum+=a[6];
    }
    cout<<sum<<endl;

}

#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<ll ,ll >
#define vi          vector<ll int>
#define vii         vector<pii>
#define mi          map<ll int,ll int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define take        rep(i,0,n) cin>>v[i];
#define MAXN        2000005

using namespace std;

void solve()
{
	ll xx,yy,zz,x,y,z;
	cin>>xx>>yy>>zz;
	x=abs(xx);
	y=abs(yy);
	z=abs(zz);
	ll a,b,c;
	cin>>a>>b>>c;
	vi v(7);
	for(ll i=1;i<=6;i++)
	{
		cin>>v[i];
	}
	if(xx>=0&&yy>=0&&zz>=0&&xx<=a&&yy<=b&&zz<=c)
	{
		cout<<0<<endl;
		return;
	}
	ll xc=0,yc=0,zc=0;
	ll cc=0;
	if(z>c)
	{
		zc=1;
		if(zz>=0)
		{
			cc=cc+v[4];

		}
		else
		{
			cc=cc+v[3];
		}

	}
	if(y>b)
	{
		yc=1;
		if(yy>=0)
		{
			cc=cc+v[2];

		}
		else
		{
			cc=cc+v[1];
		}
	}
	if(x>a)
	{
		xc=1;
		if(xx>=0)
		{
			cc=cc+v[6];

		}
		else
		{
			cc=cc+v[5];
		}
	}

	cout<<cc<<endl;

}
int main()
    {
      ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t;
        t=1;

     //   sieve();
   // cin>>t;
        while(t--)
        solve();
    }

//template
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cmath>
#include <ctime>
#include <cfloat>
#include <string.h>
#include <memory.h>
using namespace std;
#define              FOR(i,a,b)  for(int i=int(a);i<int(b);++i)
#define                       X  first
#define                       Y  second
#define                 MP(a,b)  make_pair(a,b)
typedef               long long  ll;
typedef       pair < int, int >  pii;
typedef         pair < ll, ll >  pll;
typedef pair < double, double >  pdd;
typedef          vector < int >  vi;
typedef           vector < ll >  vll;
typedef       vector < string >  vs;
typedef             set < int >  si;
typedef              set < ll >  sll;
typedef          set < string >  ss;
inline double sqr( double x ) { return x*x; }
#pragma comment(linker, "/STACK:16777216")
//template
int x, y, z, a, b, c, v[6], res = 0;

bool r(ll x1, ll y1, ll z1, ll x2, ll y2, ll z2) {
   ll a, b, c, f, g;
   a = x2 - x1;
   b = y2 - y1;
   c = z2 - z1;

   f = a*(x-x2) + b*(y-y2) + c*(z-z2);
   g = a*(x1-x2) + b*(y1-y2) + c*(z1-z2);

   if( !f )
      return false;

   return f > 0 ^ g > 0;
}

int main() {
   #ifdef _DEBUG
   freopen("in.txt","rt",stdin);
   #endif

   cin >> x >> y >> z >> a >> b >> c;
   FOR(i,0,6) cin >> v[i];

   if( r(0,b,0,0,0,0) )
      res += v[0];

   if( r(0,0,0,0,b,0) )
      res += v[1];

   if( r(0,0,c,0,0,0) )
      res += v[2];

   if( r(0,0,0,0,0,a) )
      res += v[3];

   if( r(a,0,0,0,0,0) )
      res += v[4];

   if( r(0,0,0,a,0,0) )
      res += v[5];

   cout << res;
   return 0;
}

#include <bits/stdc++.h>
using namespace std;
struct p{
double x,y,z;
};
p r,b,tmp;
int a[7],ans;
const double e=1e-9;

bool plane1(){
    double t=-r.y/(tmp.y-r.y);
    if(t<0||t>1) return 0;
    p in;
    in.x=r.x+t*(tmp.x-r.x);
    in.y=r.y+t*(tmp.y-r.y);
    in.z=r.z+t*(tmp.z-r.z);
    return in.x<=b.x+e&&in.x>=e&&in.y>=e&&in.z>=e&&in.y<=b.y+e&&in.z<=b.z+e;
}

bool plane2(){
    double t=(b.y-r.y)/(tmp.y-r.y);
    if(t<0||t>1) return 0;
    p in;
    in.x=r.x+t*(tmp.x-r.x);
    in.y=r.y+t*(tmp.y-r.y);
    in.z=r.z+t*(tmp.z-r.z);
    return in.x<=b.x+e&&in.x>=e&&in.y>=e&&in.z>=e&&in.y<=b.y+e&&in.z<=b.z+e;
}

bool plane3(){
    double t=-r.z/(tmp.z-r.z);
    if(t<0||t>1) return 0;
    p in;
    in.x=r.x+t*(tmp.x-r.x);
    in.y=r.y+t*(tmp.y-r.y);
    in.z=r.z+t*(tmp.z-r.z);
    return in.x<=b.x+e&&in.x>=e&&in.y>=e&&in.z>=e&&in.y<=b.y+e&&in.z<=b.z+e;
}

bool plane4(){
    double t=(b.z-r.z)/(tmp.z-r.z);
    if(t<0||t>1) return 0;
    p in;
    in.x=r.x+t*(tmp.x-r.x);
    in.y=r.y+t*(tmp.y-r.y);
    in.z=r.z+t*(tmp.z-r.z);
    return in.x<=b.x+e&&in.x>=e&&in.y>=e&&in.z>=e&&in.y<=b.y+e&&in.z<=b.z+e;
}

bool plane5(){
    double t=-r.x/(tmp.x-r.x);
    if(!r.x) t=0;
    if(t<0||t>1) return 0;
    p in;
    in.x=r.x+t*(tmp.x-r.x);
    in.y=r.y+t*(tmp.y-r.y);
    in.z=r.z+t*(tmp.z-r.z);
    return in.x<=b.x+e&&in.x>=e&&in.y>=e&&in.z>=e&&in.y<=b.y+e&&in.z<=b.z+e;
}

bool plane6(){
    double t=(b.x-r.x)/(tmp.x-r.x);
    if(t<0||t>1) return 0;
    p in;
    in.x=r.x+t*(tmp.x-r.x);
    in.y=r.y+t*(tmp.y-r.y);
    in.z=r.z+t*(tmp.z-r.z);
    return in.x<=b.x+e&&in.x>=e&&in.y>=e&&in.z>=e&&in.y<=b.y+e&&in.z<=b.z+e;
}

bool inplane1(){
    return r.y-tmp.y<=e&&r.y<=e;
}

bool inplane2(){
    return r.y-tmp.y<=e&&r.y-b.y<=e;
}

bool inplane3(){
    return r.z-tmp.z<=e&&r.z<=e;
}

bool inplane4(){
    return r.z-tmp.z<=e&&r.z-b.z<=e;
}

bool inplane5(){
    return r.x-tmp.x<=e&&r.x<=e;
}

bool inplane6(){
    return r.x-tmp.x<=e&&r.x-b.x<=e;
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%lf %lf %lf",&r.x,&r.y,&r.z);
    scanf("%lf %lf %lf",&b.x,&b.y,&b.z);
    for(int i=1;i<=6;i++) scanf("%d",&a[i]);
    tmp.x=b.x/2;
    tmp.z=b.z/2;
    tmp.y=0;
    ans+=a[1]*(!plane2()&&!plane3()&&!plane4()&&!plane5()&&!plane6()&&!inplane1());
    tmp.y=b.y;
    ans+=a[2]*(!plane1()&&!plane3()&&!plane4()&&!plane5()&&!plane6()&&!inplane2());
    tmp.x=b.x/2;
    tmp.z=0;
    tmp.y=b.y/2;
    ans+=a[3]*(!plane2()&&!plane1()&&!plane4()&&!plane5()&&!plane6()&&!inplane3());
    tmp.z=b.z;
    ans+=a[4]*(!plane2()&&!plane3()&&!plane1()&&!plane5()&&!plane6()&&!inplane4());
    tmp.x=0;
    tmp.z=b.z/2;
    tmp.y=b.y/2;
    ans+=a[5]*(!plane2()&&!plane3()&&!plane4()&&!plane1()&&!plane6()&&!inplane5());
    tmp.x=b.x;
    ans+=a[6]*(!plane2()&&!plane3()&&!plane4()&&!plane5()&&!plane1()&&!inplane6());
    printf("%d",ans);
    return 0;
}

#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string.h>
#include <queue>
#define st first
#define sz second
using namespace std;
typedef long long ll;
typedef pair<int,ll>ii;
const int N=100005;
const ll INF=1e14;

int main(){
 // freopen("test.in","r",stdin);
 //ios::sync_with_stdio(false);
 int a[10],sum=0;
 int x[3],y[3],z[3];
 for(int i=0;i<2;i++)cin>>x[i]>>y[i]>>z[i];
 for(int i=0;i<6;i++)cin>>a[i];
 if(y[0]<0)sum+=a[0];
 if(y[0]>y[1])sum+=a[1];
 if(z[0]<0)sum+=a[2];
 if(z[0]>z[1])sum+=a[3];
 if(x[0]<0)sum+=a[6];
 if(x[0]>z[1])sum+=a[5];
 cout<<sum;
 return 0;
}

//by avp
//07.10.2012
#pragma comment(linker, "/STACK:16777216")
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;
#define INF 1000000000

int main()
{
	long i,x,y,z,x1,y1,z1, a[6], sum = 0;
	cin >>x>>y>>z>>x1>>y1>>z1;
	for (i=0;i<6;++i)
		cin >> a[i];
	if (x>=0 && x<=x1 && y>=0 && y<=y1 && y>=0 && y<=y1) {
		cout<<0;return 0;
	}
	if (x<0) sum += a[4];
	if (x>x1) sum += a[5];
	if (y<0) sum += a[0];
	if (y>y1) sum += a[1];
	if (z<0) sum += a[2];
	if (z>z1) sum += a[3];
	cout << sum;

	return 0;
}