using System;

namespace D {
    internal class Program {
        private static void Main() {
            int x, y, z, x1, y1, z1, a1, a2, a3, a4, a5, a6;
            var line1 = Console.ReadLine().Split(' ');
            x = Convert.ToInt32(line1[0]);
            y = Convert.ToInt32(line1[1]);
            z = Convert.ToInt32(line1[2]);
            var line2 = Console.ReadLine().Split(' ');
            x1 = Convert.ToInt32(line2[0]);
            y1 = Convert.ToInt32(line2[1]);
            z1 = Convert.ToInt32(line2[2]);
            var line3 = Console.ReadLine().Split(' ');
            a1 = Convert.ToInt32(line3[0]);
            a2 = Convert.ToInt32(line3[1]);
            a3 = Convert.ToInt32(line3[2]);
            a4 = Convert.ToInt32(line3[3]);
            a5 = Convert.ToInt32(line3[4]);
            a6 = Convert.ToInt32(line3[5]);

            var 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;
            }

            Console.WriteLine(res);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForce143
{
    class C
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split();
            int pX = Convert.ToInt32(data[0]);
            int pY = Convert.ToInt32(data[1]);
            int pZ = Convert.ToInt32(data[2]);

            data = Console.ReadLine().Split();
            int x = Convert.ToInt32(data[0]);
            int y = Convert.ToInt32(data[1]);
            int z = Convert.ToInt32(data[2]);

            data = Console.ReadLine().Split();
            int a1 = Convert.ToInt32(data[0]);
            int a2 = Convert.ToInt32(data[1]);
            int a3 = Convert.ToInt32(data[2]);
            int a4 = Convert.ToInt32(data[3]);
            int a5 = Convert.ToInt32(data[4]);
            int a6 = Convert.ToInt32(data[5]);

            int sum = 0;
            if (pY > y)
                sum += a2;
            else if (pY < 0)
                sum += a1;
            if (pX > x)
                sum += a6;
            else if (pX < 0)
                sum += a5;
            if (pZ > z)
                sum += a4;
            else if (pZ < 0)
                sum += a3;

            Console.WriteLine(sum);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace D07_10_12
{
    class Program
    {
        static void Main()
        {
            string[] s = Regex.Split(Console.ReadLine(), " ");
            int vx = int.Parse(s[0]);
            int vy = int.Parse(s[1]);
            int vz = int.Parse(s[2]);
            s = Regex.Split(Console.ReadLine(), " ");
            int px = int.Parse(s[0]);
            int py = int.Parse(s[1]);
            int pz = int.Parse(s[2]);
            s = Regex.Split(Console.ReadLine(), " ");
            int n = int.Parse(s[0]);
            int v = int.Parse(s[1]);
            int d = int.Parse(s[2]);
            int b = int.Parse(s[3]);
            int l = int.Parse(s[4]);
            int p = int.Parse(s[5]);
            int sum = 0;
            if (vx > px) sum += p;
            if (vx < 0) sum += l;
            if (vy > py) sum += v;
            if (vy < 0) sum += n;
            if (vz > pz) sum += b;
            if (vz < 0) sum += d;
            Console.WriteLine("{0}", sum);

        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Linq;

namespace Codeforces
{
    internal static class Program
    {
        private const string TEST = "C1";

        private static void Solve()
        {
            var input = ReadIntArray();
            var x = input[0];
            var y = input[1];
            var z = input[2];
            input = ReadIntArray();
            var x1 = input[0];
            var y1 = input[1];
            var z1 = input[2];
            var a = ReadIntArray();
            var zV = -1;
            var xV = -1;
            var yV = -1;
            if(z > z1)
            {
                zV = a[4-1];
            }
            else if (z < 0)
            {
                zV = a[3-1];
            }
            else
                zV = 0;

            if(x > x1)
            {
                xV = a[6 - 1];
            }
            else if(x<0)
            {
                xV = a[5 - 1];
            }
            else
            {
                xV = 0;
            }

            if(y >y1)
            {
                yV = a[2 - 1];
            }
            else if(y <0)
            {
                yV = a[1 - 1];
            }
            else
            {
                yV = 0;
            }
            var res = xV + yV + zV;
            WriteLine(res);
        }

        private static void Main()
        {
            if (Debugger.IsAttached)
            {
                Console.SetIn(new StreamReader(String.Format(@"..\..\..\..\Tests\{0}.in", TEST)));
            }

            Solve();

            if (Debugger.IsAttached)
            {
                Console.In.Close();
                Console.SetIn(new StreamReader(Console.OpenStandardInput()));
                Console.ReadLine();
            }
        }

        #region Reader

        private static string Read()
        {
            return Console.ReadLine();
        }

        private static void Read(out int n1, out int n2)
        {
            var input = ReadArray();
            n1 = int.Parse(input[0]);
            n2 = int.Parse(input[1]);
        }

        private static void Read(out int n1, out int n2, out int n3)
        {
            var input = ReadArray();
            n1 = int.Parse(input[0]);
            n2 = int.Parse(input[1]);
            n3 = int.Parse(input[2]);
        }

        private static string[] ReadArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static List<int> ReadIntArray()
        {
            var input = Console.ReadLine().Split(' ').Select(Int32.Parse).ToList();
            return input;
        }

        private static int ReadInt()
        {
            return Int32.Parse(Console.ReadLine());
        }

        private static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        private static List<long> ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToList();
        }

        private static double ReadDouble()
        {
            return double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
        }

        private static List<double> ReadDoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(d => double.Parse(d, CultureInfo.InvariantCulture)).ToList();
        }

        private static void WriteLine(object value)
        {
            Console.WriteLine(value);
        }

        private static void WriteLine(int value)
        {
            Console.WriteLine(value);
        }

        private static void WriteLine(double value)
        {
            Console.WriteLine(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void WriteLine(long value)
        {
            Console.WriteLine(value);
        }

        private static void WriteLine(double value, string stringFormat)
        {
            Console.WriteLine(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }

        private static void Write(object value)
        {
            Console.Write(value);
        }

        private static void Write(int value)
        {
            Console.Write(value);
        }

        private static void Write(double value)
        {
            Console.Write(value.ToString(CultureInfo.InvariantCulture));
        }

        private static void Write(long value)
        {
            Console.Write(value);
        }

        private static void Write(double value, string stringFormat)
        {
            Console.Write(value.ToString(stringFormat, CultureInfo.InvariantCulture));
        }
        #endregion
    }
}

using System;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System.Threading;

namespace CodeForces
{
	internal class A
	{

		private void Solve()
		{
			int x = NextInt(), y = NextInt(), z = NextInt(), x1 = NextInt(), y1 = NextInt(), z1 = NextInt();
			int[] a = new int[6];
			for ( int i = 0; i < 6; ++i ) a[i] = NextInt();
			int sum = 0;
			if ( y < 0 ) sum += a[0];
			if ( y > y1 ) sum += a[1];
			if ( z < 0 ) sum += a[2];
			if ( z > z1 ) sum += a[3];
			if ( x < 0 ) sum += a[4];
			if ( x > x1 ) sum += a[5];

			Out.WriteLine( sum );
		}

		#region Local wireup

		public int NextInt()
		{
			return _in.NextInt();
		}

		public long NextLong()
		{
			return _in.NextLong();
		}

		public string NextLine()
		{
			return _in.NextLine();
		}

		public double NextDouble()
		{
			return _in.NextDouble();
		}

		readonly Scanner _in = new Scanner();
		static readonly TextWriter Out = Console.Out;

		void Start()
		{
#if !ONLINE_JUDGE
			var timer = new Stopwatch();
			timer.Start();
#endif
			var t = new Thread( Solve, 20000000 );
			t.Start();
			t.Join();
#if !ONLINE_JUDGE
			timer.Stop();
			Console.WriteLine( string.Format( CultureInfo.InvariantCulture, "Done in {0} seconds.\nPress <Enter> to exit.", timer.ElapsedMilliseconds / 1000.0 ) );
			Console.ReadLine();
#endif
		}

		static void Main()
		{
			new A().Start();
		}

		class Scanner : IDisposable
		{
			#region Fields

			readonly TextReader _reader;
			readonly int _bufferSize;
			readonly bool _closeReader;
			readonly char[] _buffer;
			int _length, _pos;

			#endregion

			#region .ctors

			public Scanner( TextReader reader, int bufferSize, bool closeReader )
			{
				_reader = reader;
				_bufferSize = bufferSize;
				_closeReader = closeReader;
				_buffer = new char[_bufferSize];
				FillBuffer( false );
			}

			public Scanner( TextReader reader, bool closeReader ) : this( reader, 1 << 16, closeReader ) { }

			public Scanner( string fileName ) : this( new StreamReader( fileName, Encoding.Default ), true ) { }

#if ONLINE_JUDGE
			public Scanner() : this( Console.In, false ) { }
#else
			public Scanner() : this( "input.txt" ) { }
#endif

			#endregion

			#region IDisposable Members

			public void Dispose()
			{
				if ( _closeReader )
				{
					_reader.Close();
				}
			}

			#endregion

			#region Properties

			public bool Eof
			{
				get
				{
					if ( _pos < _length ) return false;
					FillBuffer( false );
					return _pos >= _length;
				}
			}

			#endregion

			#region Methods

			private char NextChar()
			{
				if ( _pos < _length ) return _buffer[_pos++];
				FillBuffer( true );
				return _buffer[_pos++];
			}

			private char PeekNextChar()
			{
				if ( _pos < _length ) return _buffer[_pos];
				FillBuffer( true );
				return _buffer[_pos];
			}

			private void FillBuffer( bool throwOnEof )
			{
				_length = _reader.Read( _buffer, 0, _bufferSize );
				if ( throwOnEof && Eof )
				{
					throw new IOException( "Can't read beyond the end of file" );
				}
				_pos = 0;
			}

			public int NextInt()
			{
				var neg = false;
				int res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public long NextLong()
			{
				var neg = false;
				long res = 0;
				SkipWhitespaces();
				if ( !Eof && PeekNextChar() == '-' )
				{
					neg = true;
					_pos++;
				}
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					var c = NextChar();
					if ( c < '0' || c > '9' ) throw new ArgumentException( "Illegal character" );
					res = 10 * res + c - '0';
				}
				return neg ? -res : res;
			}

			public string NextLine()
			{
				SkipUntilNextLine();
				if ( Eof ) return "";
				var builder = new StringBuilder();
				while ( !Eof && !IsEndOfLine( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return builder.ToString();
			}

			public double NextDouble()
			{
				SkipWhitespaces();
				var builder = new StringBuilder();
				while ( !Eof && !IsWhitespace( PeekNextChar() ) )
				{
					builder.Append( NextChar() );
				}
				return double.Parse( builder.ToString(), CultureInfo.InvariantCulture );
			}

			private void SkipWhitespaces()
			{
				while ( !Eof && IsWhitespace( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private void SkipUntilNextLine()
			{
				while ( !Eof && IsEndOfLine( PeekNextChar() ) )
				{
					++_pos;
				}
			}

			private static bool IsWhitespace( char c )
			{
				return c == ' ' || c == '\t' || c == '\n' || c == '\r';
			}

			private static bool IsEndOfLine( char c )
			{
				return c == '\n' || c == '\r';
			}

			#endregion
		}

		#endregion
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CodeForces
{
    class R143_Div2_D
    {
        static void Main(string[] args)
        {
            string[] s = (Console.ReadLine().Split());
            int x = Convert.ToInt32(s[0]);
            int y = Convert.ToInt32(s[1]);
            int z = Convert.ToInt32(s[2]);

            s = (Console.ReadLine().Split());
            int x1 = Convert.ToInt32(s[0]);
            int y1 = Convert.ToInt32(s[1]);
            int z1 = Convert.ToInt32(s[2]);

            s = (Console.ReadLine().Split());
            int[] a = new int[7];
            for (int i = 1; i <= 6; i++)
            {
                a[i] = Convert.ToInt32(s[i-1]);
            }

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

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

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

            Console.WriteLine(cnt);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, y, z;
            string[] input = Console.ReadLine().Split(' ');
            x = int.Parse(input[0]);
            y = int.Parse(input[1]);
            z = int.Parse(input[2]);
            int X, Y, Z;
            input = Console.ReadLine().Split(' ');
            X = int.Parse(input[0]);
            Y = int.Parse(input[1]);
            Z = int.Parse(input[2]);
            input = Console.ReadLine().Split(' ');
            int[] a = new int[6];
            for (int i = 0; i < 6; i++)
                a[i] = int.Parse(input[i]);
            int ans = 0;
            for (int i = 0; i < 6; i++)
            {
                switch (i)
                {
                    case 0:
                        if (y < 0)
                            ans += a[i];
                        break;
                    case 1:
                        if (y > Y)
                            ans += a[i];
                        break;
                    case 2:
                        if (z < 0)
                            ans += a[i];
                        break;
                    case 3:
                        if (z > Z)
                            ans += a[i];
                        break;
                    case 4:
                        if (x < 0)
                            ans += a[i];
                        break;
                    case 5:
                        if (x > X)
                            ans += a[i];
                        break;
                }
            }
            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Temp
{
    struct PointInt
    {
        public long X;

        public long Y;

        public PointInt(long x, long y)
            : this()
        {
            X = x;
            Y = y;
        }

        public static PointInt operator +(PointInt a, PointInt b)
        {
            return new PointInt(a.X + b.X, a.Y + b.Y);
        }

        public static PointInt operator -(PointInt a, PointInt b)
        {
            return new PointInt(a.X - b.X, a.Y - b.Y);
        }

        public static PointInt operator *(PointInt a, long k)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public static PointInt operator *(long k, PointInt a)
        {
            return new PointInt(k * a.X, k * a.Y);
        }

        public static bool operator ==(PointInt a, PointInt b)
        {
            return (a.X == b.X) && (a.Y == b.Y);
        }

        public static bool operator !=(PointInt a, PointInt b)
        {
            return !(a == b);
        }

        public bool IsInsideRectangle(long l, long b, long r, long t)
        {
            return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);
        }

        public bool Equals(PointInt other)
        {
            return other.X == X && other.Y == Y;
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (obj.GetType() != typeof (PointInt)) return false;
            return Equals((PointInt) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                return (X.GetHashCode() * 397) ^ Y.GetHashCode();
            }
        }
    }

    struct LineInt
    {
        public LineInt(PointInt a, PointInt b)
            : this()
        {
            A = a.Y - b.Y;
            B = b.X - a.X;
            C = a.X * b.Y - a.Y * b.X;
        }

        public long A, B, C;

        public bool Contains(PointInt p)
        {
            return A * p.X + B * p.Y + C == 0;
        }
    }

    class MatrixInt
    {
        private readonly long[,] m_Matrix;

        public int Size
        {
            get
            {
                return m_Matrix.GetLength(0) - 1;
            }
        }

        public long Mod { get; private set; }

        public MatrixInt(int size, long mod = 0)
        {
            m_Matrix = new long[size + 1, size + 1];
            Mod = mod;
        }

        public MatrixInt(long[,] matrix, long mod = 0)
        {
            this.m_Matrix = matrix;
            Mod = mod;
        }

        public static MatrixInt GetIdentityMatrix(int size, long mod = 0)
        {
            long[,] matrix = new long[size + 1, size + 1];

            for (int i = 1; i <= size; i++)
            {
                matrix[i, i] = 1;
            }

            return new MatrixInt(matrix, mod);
        }

        public long this[int i, int j]
        {
            get
            {
                return m_Matrix[i, j];
            }

            set
            {
                m_Matrix[i, j] = value;
            }
        }

        public static MatrixInt operator +(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);
            long[,] c = new long[n, n];
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    c[i, j] = a[i, j] + b[i, j];
                }
            }

            if (mod > 0)
            {
                for (int i = 1; i <= n; i++)
                {
                    for (int j = 1; j <= n; j++)
                    {
                        c[i, j] %= mod;
                    }
                }
            }

            return new MatrixInt(c, mod);
        }

        public static MatrixInt operator *(MatrixInt a, MatrixInt b)
        {
            int n = a.Size;
            long mod = Math.Max(a.Mod, b.Mod);

            long[,] c = new long[n, n];

            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    for (int k = 1; k <= n; k++)
                    {
                        c[i, j] += a[i, k] * b[k, j];
                        if (mod > 0)
                        {
                            c[i, j] %= mod;
                        }
                    }
                }
            }

            return new MatrixInt(c, mod);
        }
    }

    public static class Permutations
    {
        public static int[] GetRandomPermutation(int n)
        {
            int[] p = new int[n];
            for (int i = 0; i < n; i++)
            {
                p[i] = i;
            }

            Random random = new Random();
            for (int i = n - 1; i > 0; i--)
            {
                int j = random.Next(i + 1);
                int tmp = p[i];
                p[i] = p[j];
                p[j] = tmp;
            }

            return p;
        }
    }

    static class Extensions
    {
        public static T[] Shuffle<T>(this T[] array)
        {
            int length = array.Length;
            int[] p = Permutations.GetRandomPermutation(length);
            T[] result = new T[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = array[p[i]];
            }

            return result;
        }
    }

    static class Algebra
    {
        public static long Phi(long n)
        {
            long result = n;
            for (long i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    while (n % i == 0)
                    {
                        n /= i;
                    }

                    result -= result / i;
                }
            }

            if (n > 1)
            {
                result -= result / n;
            }

            return result;
        }

        public static long BinPower(long a, long n, long mod)
        {
            long result = 1;

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result = (result * a) % mod;
                }

                a = (a * a) % mod;
                n >>= 1;
            }

            return result;
        }

        public static MatrixInt MatrixBinPower(MatrixInt a, long n)
        {
            MatrixInt result = new MatrixInt(a.Size);

            while (n > 0)
            {
                if ((n & 1) != 0)
                {
                    result *= a;
                }

                a *= a;
                n >>= 1;
            }

            return result;
        }

        public static long Gcd(long a, long b)
        {
            return b == 0 ? a : Gcd(b, a % b);
        }

        public static long ExtendedGcd(long a, long b, out long x, out long y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }

            long x1;
            long y1;
            long d = ExtendedGcd(b, a % b, out x1, out y1);
            x = y1;
            y = x1 - (a / b) * y1;
            return d;
        }

        public static long Lcm(long a, long b)
        {
            return (a / Gcd(a, b)) * b;
        }

        public static bool[] GetPrimes(int n)
        {
            n = Math.Max(n, 2);
            bool[] prime = new bool[n + 1];
            for (int i = 2; i <= n; i++)
            {
                prime[i] = true;
            }

            for (int i = 2; i * i <= n; i++)
            {
                if (prime[i])
                {
                    if ((long)i * i <= n)
                    {
                        for (int j = i * i; j <= n; j += i)
                        {
                            prime[j] = false;
                        }
                    }
                }
            }

            return prime;
        }

        public static long GetFibonacciNumber(long n, long mod = 0)
        {
            long[,] matrix = new long[,] { { 0, 0, 0 }, { 0, 0, 1 }, { 0, 1, 1 } };

            MatrixInt result = MatrixBinPower(new MatrixInt(matrix, mod), n);

            return result[2, 2];
        }

        public static long[] GetFibonacciSequence(int n)
        {
            long[] result = new long[n];
            result[0] = result[1] = 1;

            for (int i = 2; i < n; i++)
            {
                result[i] = result[i - 1] + result[i - 2];
            }

            return result;
        }

        public static long GetInverseElement(long a, long mod)
        {
            long x, y;
            long g = ExtendedGcd(a, mod, out x, out y);

            if (g != 1)
            {
                return -1;
            }

            return ((x % mod) + mod) % mod;
        }

        public static long[] GetAllInverseElements(long mod)
        {
            long[] result = new long[mod];
            result[1] = 1;
            for (int i = 2; i < mod; i++)
            {
                result[i] = (mod - (((mod / i) * result[mod % i]) % mod)) % mod;
            }

            return result;
        }

        public static int GetMinimalPrimeDivisor(int n)
        {
            for (int i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    return i;
                }
            }

            return n;
        }
    }

    internal static class Reader
    {
        public static void ReadInt(out int a)
        {
            int[] number = new int[1];
            ReadInt(number);
            a = number[0];
        }

        public static void ReadInt(out int a, out int b)
        {
            int[] numbers = new int[2];
            ReadInt(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadInt(out int int1, out int int2, out int int3)
        {
            int[] numbers = new int[3];
            ReadInt(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static void ReadLong(out long a)
        {
            long[] number = new long[1];
            ReadLong(number);
            a = number[0];
        }

        public static void ReadLong(out long a, out long b)
        {
            long[] numbers = new long[2];
            ReadLong(numbers);
            a = numbers[0];
            b = numbers[1];
        }

        public static void ReadLong(out long int1, out long int2, out long int3)
        {
            long[] numbers = new long[3];
            ReadLong(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
        }

        public static void ReadLong(out long int1, out long int2, out long int3, out long int4)
        {
            long[] numbers = new long[4];
            ReadLong(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
            int4 = numbers[3];
        }

        public static void ReadInt(int[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = int.Parse(list[i]);
            }
        }

        public static int[] ReadDigits()
        {
// ReSharper disable AssignNullToNotNullAttribute
// ReSharper disable SpecifyACultureInStringConversionExplicitly
            return Console.ReadLine().Select(x => int.Parse(x.ToString())).ToArray();
// ReSharper restore SpecifyACultureInStringConversionExplicitly
// ReSharper restore AssignNullToNotNullAttribute
        }

        public static void ReadLong(long[] numbers)
        {
            // ReSharper disable PossibleNullReferenceException
            var list = Console.ReadLine().Split();
            // ReSharper restore PossibleNullReferenceException

            int count = Math.Min(numbers.Length, list.Length);

            for (int i = 0; i < count; i++)
            {
                numbers[i] = long.Parse(list[i]);
            }
        }
    }

    static class MyMath
    {
        public static int GetMinimalPrimeDivisor(int n)
        {
            for (int i = 2; i * i <= n; i++)
            {
                if (n % i == 0)
                {
                    return i;
                }
            }

            return n;
        }

        public static long Sqr(long x)
        {
            return x * x;
        }
    }

    public interface IGraph
    {
        int Vertices { get; set; }

        IList<int> this[int i] { get; }

        void AddEdge(int u, int v);

        void AddOrientedEdge(int u, int v);
    }

    public class Graph : IGraph
    {
        private readonly List<int>[] m_Edges;

        public int Vertices { get; set; }

        public IList<int> this[int i]
        {
            get
            {
                return this.m_Edges[i];
            }
        }

        public Graph(int vertices)
        {
            this.Vertices = vertices;

            this.m_Edges = new List<int>[vertices];

            for (int i = 0; i < vertices; i++)
            {
                this.m_Edges[i] = new List<int>();
            }
        }

        public void AddEdge(int u, int v)
        {
            this.AddOrientedEdge(u, v);
            this.AddOrientedEdge(v, u);
        }

        public void AddOrientedEdge(int first, int second)
        {
            this.m_Edges[first].Add(second);
        }

        public int[] Bfs(int start)
        {
            int[] d = new int[Vertices];
            for (int i = 0; i < Vertices; i++)
            {
                d[i] = -1;
            }

            Queue<int> queue = new Queue<int>();
            queue.Enqueue(start);
            d[start] = 0;

            while (queue.Count > 0)
            {
                int v = queue.Dequeue();
                foreach (int t in this.m_Edges[v].Where(t => d[t] == -1))
                {
                    queue.Enqueue(t);
                    d[t] = d[v] + 1;
                }
            }

            return d;
        }
    }

    class SimpleSumTable
    {
        private readonly int[,] m_Sum;

        public SimpleSumTable(int n, int m, int[,] table)
        {
            m_Sum = new int[n + 1, m + 1];

            for (int i = 1; i < n + 1; i++)
            {
                for (int j = 1; j < m + 1; j++)
                {
                    m_Sum[i, j] = m_Sum[i, j - 1] + m_Sum[i - 1, j] - m_Sum[i - 1, j - 1] + table[i, j];
                }
            }
        }

        public int GetSum(int l, int b, int r, int t)
        {
            return m_Sum[r, t] - m_Sum[r, b] - m_Sum[l, t] + m_Sum[l, b];
        }
    }

    class SegmentTreeSimpleInt<T>
    {
        public int Size { get; private set; }

        private readonly T[] m_Tree;

        private readonly Func<T, T, T> m_Operation;

        private readonly T m_Null;

        public SegmentTreeSimpleInt(int size, Func<T, T, T> operation, T nullElement, IList<T> array = null)
        {
            this.Size = size;
            this.m_Operation = operation;
            this.m_Null = nullElement;

            m_Tree = new T[4 * size];
            if (array != null)
            {
                this.Build(array, 1, 0, size - 1);
            }
        }

        private void Build(IList<T> array, int v, int tl, int tr)
        {
            if (tl == tr)
            {
                m_Tree[v] = array[tl];
            }
            else
            {
                int tm = (tl + tr) / 2;
                this.Build(array, 2 * v, tl, tm);
                this.Build(array, 2 * v + 1, tm + 1, tr);
                this.CalculateNode(v);
            }
        }

        public T GetSum(int l, int r)
        {
            return GetSum(1, 0, Size - 1, l, r);
        }

        private T GetSum(int v, int tl, int tr, int l, int r)
        {
            if (l > r)
            {
                return m_Null;
            }

            if (l == tl && r == tr)
            {
                return m_Tree[v];
            }

            int tm = (tl + tr) / 2;

            return this.m_Operation(GetSum(2 * v, tl, tm, l, Math.Min(r, tm)), GetSum(2 * v + 1, tm + 1, tr, Math.Max(l, tm + 1), r));
        }

        public void Update(int pos, T newValue)
        {
            Update(1, 0, Size - 1, pos, newValue);
        }

        private void Update(int v, int tl, int tr, int pos, T newValue)
        {
            if (tl == tr)
            {
                m_Tree[v] = newValue;
            }
            else
            {
                int tm = (tl + tr) / 2;
                if (pos <= tm)
                {
                    Update(2 * v, tl, tm, pos, newValue);
                }
                else
                {
                    Update(2 * v + 1, tm + 1, tr, pos, newValue);
                }
                this.CalculateNode(v);
            }
        }

        private void CalculateNode(int v)
        {
            m_Tree[v] = this.m_Operation(m_Tree[2 * v], m_Tree[2 * v + 1]);
        }
    }

    internal static class Geometry
    {
        public static long Vect(PointInt a, PointInt b, PointInt c)
        {
            return (b.X - a.X) * (c.Y - a.Y) - (b.Y - a.Y) * (c.X - a.X);
        }

        public static long Area(PointInt a, PointInt b, PointInt c)
        {
            return Math.Abs(Vect(a, b, c));
        }
    }

    struct Pair<TFirst, TSecond>
    {
        public Pair(TFirst first, TSecond second)
            : this()
        {
            this.First = first;
            this.Second = second;
        }

        public TFirst First { set; get; }

        public TSecond Second { set; get; }
    }

    class PriorityQueue<T>
    {
        public PriorityQueue(Comparison<T> comparison = null)
        {
            if (comparison == null)
            {
                if (typeof(T).GetInterfaces().Any(i => i == typeof(IComparable)))
                {
                    m_Comparison = (a, b) => ((IComparable<T>)a).CompareTo(b);
                }
                else
                {
                    throw new ApplicationException("Add comparer");
                }
            }
            else
            {
                m_Comparison = comparison;
            }
        }

        public int Count { get; private set; }

        public void Enqueue(T item)
        {
            m_List.Add(item);
            this.Count++;
            Up(this.Count);
        }

        public T Peek()
        {
            return m_List[0];
        }

        public T Dequeue()
        {
            if (this.Count > 0)
            {
                var result = m_List[0];

                m_List[0] = m_List[this.Count - 1];
                m_List.RemoveAt(this.Count - 1);
                this.Count--;
                this.Down(1);

                return result;
            }
            throw new ApplicationException("Couldn't get element from empty queue");
        }

        private readonly List<T> m_List = new List<T>();

        private readonly Comparison<T> m_Comparison;

        private void Up(int index)
        {
            while (index > 1 && m_Comparison.Invoke(m_List[index - 1], m_List[index / 2 - 1]) > 0)
            {
                this.Swap(index - 1, index / 2 - 1);

                index = index / 2;
            }
        }

        private void Down(int index)
        {
            while (2 * index <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index - 1]) < 0 ||
                   2 * index + 1 <= this.Count && m_Comparison.Invoke(m_List[index - 1], m_List[2 * index]) < 0)
            {
                if (2 * index + 1 > this.Count || m_Comparison.Invoke(m_List[2 * index - 1], m_List[2 * index]) > 0)
                {
                    this.Swap(index - 1, 2 * index - 1);
                    index = 2 * index;
                }
                else
                {
                    this.Swap(index - 1, 2 * index);
                    index = 2 * index + 1;
                }
            }
        }

        private void Swap(int i, int j)
        {
            var tmp = m_List[i];
            m_List[i] = m_List[j];
            m_List[j] = tmp;
        }
    }

    class Program
    {
        private static StreamReader InputStream;

        private static StreamWriter OutStream;

        private static void OpenFiles(string inputName, string outputName)
        {
            InputStream = File.OpenText(inputName);
            Console.SetIn(InputStream);

            OutStream = File.CreateText(outputName);
            Console.SetOut(OutStream);
        }

        private static void CloseFiles()
        {
            OutStream.Flush();

            InputStream.Dispose();
            OutStream.Dispose();
        }

        static void Main()
        {
           // OpenFiles("input.txt", "output.txt");

            new Solution().Solve();

           // CloseFiles();
        }
    }

    internal class Solution
    {
        public void Solve()
        {
            int x, y, z, x1, y1, z1;
            Reader.ReadInt(out x, out y, out z);
            Reader.ReadInt(out x1, out y1, out z1);
            int[] a = new int[6];
            Reader.ReadInt(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];
            }
            Console.WriteLine(ans);
        }
    }
}

using System;
using System.IO;
using System.Text;

namespace Magic_Box
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            int x = Next(), y = Next(), z = Next();
            int x1 = Next(), y1 = Next(), z1 = Next();

            var nn = new int[6];
            for (int i = 0; i < 6; i++)
            {
                nn[i] = Next();
            }

            int sum = 0;

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

            writer.WriteLine(sum);
            writer.Flush();
        }

        private static int Next()
        {
            int c;
            int m = 1;
            do
            {
                c = reader.Read();
                if (c == '-')
                    m = -1;
            } while (c < '0' || c > '9');
            int res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return m*res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}