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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int a1 = int.Parse(s[0]);
            int a2 = int.Parse(s[1]);

            int p = a2 - a1;

            for (int i = 2; i < s.Count(); i++)
            {
                int t = int.Parse(s[i]);
                if (a2 + p != t)
                {
                    Console.Write(0);
                    return;
                }
                a2 = t;
            }

            Console.Write(1);
        }
    }
}


using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');

            int a1 = int.Parse(s[0]);
            int a2 = int.Parse(s[1]);

            int p = a2 - a1;

            for (int i = 2; i < s.Count(); i++)
            {
                int t = int.Parse(s[i]);
                if (a2 + p != t)
                {
                    Console.Write(0);
                    return;
                }
                a2 = t;
            }

            Console.Write(1);
        }
    }
}


using System;
class test
{
    static void Main()
    {
        int []a = new int [2];
        int []b = new int [2];
        int []c = new int [2];

        string last = "";
        string last2 = "";

        for(int i=0;i<3;i++)
            {
                string []tmp = Console.ReadLine().Split();
                if(i == 0)
                    {
                        a[0] = int.Parse(tmp[0]);
                        a[1] = int.Parse(tmp[1]);
                    }
                if(i == 1)
                    {
                        b[0] = int.Parse(tmp[0]);
                        b[1] = int.Parse(tmp[1]);
                    }
               if(i == 2)
                    {
                        c[0] = int.Parse(tmp[0]);
                        c[1] = int.Parse(tmp[1]);
                    }
            }

         if(b[1]>a[1]){last += "U";}
         if(b[1]<a[1]){last += "D";}
         if(b[0]>a[0]){last += "R";}
         if(b[0]<a[0]){last += "L";}

         if(c[1]>b[1]){last2 += "U";}
         if(c[1]<b[1]){last2 += "D";}
         if(c[0]>b[0]){last2 += "R";}
         if(c[0]<b[0]){last2 += "L";}

         if(last == last2){Console.WriteLine("TOWARDS");}

         else
             {
                 if(last == "U")
                     {
                         if(last2 == "R"){Console.WriteLine("RIGHT");}
                         if(last2 == "L"){Console.WriteLine("LEFT");}
                     }
                 if(last == "D")
                     {
                         if(last2 == "R"){Console.WriteLine("LEFT");}
                         if(last2 == "L"){Console.WriteLine("RIGHT");}
                     }
                 if(last == "L")
                     {
                         if(last2 == "U"){Console.WriteLine("RIGHT");}
                         if(last2 == "D"){Console.WriteLine("LEFT");}
                     }
                 if(last == "UR")
                     {
                         if(last2 == "UL"){Console.WriteLine("LEFT");}
                         if(last2 == "DR"){Console.WriteLine("RIGHT");}
                     }
                 if(last == "UL")
                     {
                         if(last2 == "UR"){Console.WriteLine("RIGHT");}
                         if(last2 == "DL"){Console.WriteLine("LEFT");}
                     }
                 if(last == "DR")
                     {
                         if(last2 == "UR"){Console.WriteLine("LEFT");}
                         if(last2 == "DL"){Console.WriteLine("RIGHT");}
                     }
                 if(last == "DL")
                     {
                         if(last2 == "UL"){Console.WriteLine("RIGHT");}
                         if(last2 == "DR"){Console.WriteLine("LEFT");}
                     }
             }
    }

}


// Just split the path string and apply the changes.

using System;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        int x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0;
        string buf = Console.ReadLine();
        string[] vals = buf.Split(' ');
        x1 = Convert.ToInt32(vals[0]);
        y1 = Convert.ToInt32(vals[1]);

        buf = Console.ReadLine();
        vals = buf.Split(' ');
        x2 = Convert.ToInt32(vals[0]);
        y2 = Convert.ToInt32(vals[1]);

        buf = Console.ReadLine();
        vals = buf.Split(' ');
        x3 = Convert.ToInt32(vals[0]);
        y3 = Convert.ToInt32(vals[1]);

        int crs = (x2-x1)*(y3-y2)-(y2-y1)*(x3-x2);
        if(crs == 0) {
            Console.WriteLine("TOWARDS");
        }
        else if(crs < 0) {
            Console.WriteLine("RIGHT");
        }
        else if(crs > 0) {
            Console.WriteLine("LEFT");
        }
    }
}


using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
class Program{
	static void Main() {
		int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
		long[] v1 = new long[2]{b[0] - a[0], b[1] - a[1]};
		long[] v2 = new long[2]{c[0] - b[0], c[1] - b[1]};
		long product = (v1[0] * v2[1]) - (v1[1] * v2[0]);
		Console.WriteLine(product);
		if(product == 0)
			Console.WriteLine("TOWARDS");
		else if(product > 0)
			Console.WriteLine("LEFT");
		else
			Console.WriteLine("RIGHT");
	}
}


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

namespace _227A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');
            string[] b = Console.ReadLine().Split(' ');
            string[] c = Console.ReadLine().Split(' ');

            int xa = Convert.ToInt32(a[0]);
            int ya = Convert.ToInt32(a[1]);
            int xb = Convert.ToInt32(b[0]);
            int yb = Convert.ToInt32(b[1]);
            int xc = Convert.ToInt32(c[0]);
            int yc = Convert.ToInt32(c[1]);

            int k = (xb - xa) * (yc - yb) - (xc - xb) * (yb - ya);

            if (k > 0) Console.WriteLine("LEFT");
            else
            {
                if (k == 0) Console.WriteLine("TOWARDS");
                else Console.WriteLine("RIGHT");
            }
            Console.ReadLine();
        }
    }
}


using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
class Program{
	static void Main() {
		int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int[] v1 = new int[2]{b[0] - a[0], b[1] - a[1]};
		int[] v2 = new int[2]{c[0] - b[0], c[1] - b[1]};
		int product = (v1[0] * v2[1]) - (v1[1] * v2[0]);
		if(product == 0)
			Console.WriteLine("TOWARDS");
		else if(product > 0)
			Console.WriteLine("LEFT");
		else
			Console.WriteLine("RIGHT");
	}
}


using System;

namespace ConsoleApplication1
{
    public class Program
    {
        static void Main()
        {
            string[] a = Console.ReadLine().Split(' '),
                     b = Console.ReadLine().Split(' '),
                     c = Console.ReadLine().Split(' ');
            string k = Solver(Int32.Parse(a[0]), Int32.Parse(a[1]), Int32.Parse(b[0]),
                              Int32.Parse(b[1]), Int32.Parse(c[0]), Int32.Parse(c[1]));
            Console.WriteLine(k);
        }

        public static string Solver(int ax, int ay, int bx, int by, int cx, int cy)
        {

            int[,] mat = new int[3, 3] { { 1, 1, 1 }, { bx - ax, by - ay, 0 }, { cx - bx, cy - by, 0 } };
            int k = mat[1, 0] * mat[2, 1] - mat[1, 1] * mat[2, 0];
            if (k > 0) return "LEFT";
            if (k < 0) return "RIGHT";
            return "TOWARDS";

        }
    }
}


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

namespace CodeForces
{
    class R140_Div2_227A
    {
        static void Main(string[] args)
        {
            string[] s;
            s = (Console.ReadLine().Split());
            int ax = Convert.ToInt32(s[0]);
            int ay = Convert.ToInt32(s[1]);
            s = (Console.ReadLine().Split());
            int bx = Convert.ToInt32(s[0]);
            int by = Convert.ToInt32(s[1]);
            s = (Console.ReadLine().Split());
            int cx = Convert.ToInt32(s[0]);
            int cy = Convert.ToInt32(s[1]);

            int d = (cx - ax) * (by - ay) - (bx - ax) * (cy - ay);
            string ret;
            if (d == 0)
                ret = "TOWARDS";
            else if (d < 0)
                ret = "LEFT";
            else // d > 0
                ret = "RIGHT";
            Console.WriteLine(ret);
        }
    }
}


// Just split the path string and apply the changes.

using System;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        long x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0;
        string buf = Console.ReadLine();
        string[] vals = buf.Split(' ');
        x1 = Convert.ToInt32(vals[0]);
        y1 = Convert.ToInt32(vals[1]);

        buf = Console.ReadLine();
        vals = buf.Split(' ');
        x2 = Convert.ToInt32(vals[0]);
        y2 = Convert.ToInt32(vals[1]);

        buf = Console.ReadLine();
        vals = buf.Split(' ');
        x3 = Convert.ToInt32(vals[0]);
        y3 = Convert.ToInt32(vals[1]);

        long crs = (x2-x1)*(y3-y2)-(y2-y1)*(x3-x2);
        if(crs == 0) {
            Console.WriteLine("TOWARDS");
        }
        else if(crs < 0) {
            Console.WriteLine("RIGHT");
        }
        else if(crs > 0) {
            Console.WriteLine("LEFT");
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Int64 x1, y1, x2, y2, x3, y3, d;

            string[] inp = null;

            inp = Console.ReadLine().ToString().Split(' ');
            x1 = Convert.ToInt64(inp[0]);
            y1 = Convert.ToInt64(inp[1]);

            inp = Console.ReadLine().ToString().Split(' ');
            x2 = Convert.ToInt64(inp[0]);
            y2 = Convert.ToInt64(inp[1]);

            inp = Console.ReadLine().ToString().Split(' ');
            x3 = Convert.ToInt64(inp[0]);
            y3 = Convert.ToInt64(inp[1]);

            d = (x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1);

            if(d==0)
                Console.WriteLine("TOWARDS");
            else if (d < 0)
                Console.WriteLine("LEFT");
            else
                Console.WriteLine("RIGHT");

        }
    }
}


using System;

namespace ConsoleApplication1
{
    public class Program
    {
        static void Main()
        {
            string[] a = Console.ReadLine().Split(' '),
                     b = Console.ReadLine().Split(' '),
                     c = Console.ReadLine().Split(' ');
            string k = Solver(Int32.Parse(a[0]), Int32.Parse(a[1]), Int32.Parse(b[0]),
                              Int32.Parse(b[1]), Int32.Parse(c[0]), Int32.Parse(c[1]));
            Console.WriteLine(k);
        }

        public static string Solver(int ax, int ay, int bx, int by, int cx, int cy)
        {

            Int64[,] mat = new Int64[3, 3] { { 1, 1, 1 }, { bx - ax, by - ay, 0 }, { cx - bx, cy - by, 0 } };
            Int64 k = mat[1, 0] * mat[2, 1] - mat[1, 1] * mat[2, 0];
            if (k > 0) return "LEFT";
            if (k < 0) return "RIGHT";
            return "TOWARDS";

        }
    }
}


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

namespace ProblemSet
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');
            string[] b = Console.ReadLine().Split(' ');
            string[] c = Console.ReadLine().Split(' ');

            long ax = long.Parse(a[0]);
            long ay = long.Parse(a[1]);

            long bx = long.Parse(b[0]);
            long by = long.Parse(b[1]);

            long cx = long.Parse(c[0]);
            long cy = long.Parse(c[1]);

            long[] ab = { (bx - ax), (by - ay), 0 - 0 };
            long[] bc = { (cx - bx), (cy - by), 0 - 0 };

            long[] prVekt = { ab[1]*bc[2]-ab[2]*bc[1], ab[2]*bc[0]-ab[0]*bc[2], ab[0]*bc[1]-ab[1]*bc[0] };

            if (prVekt[2] > 0)
            {
                Console.WriteLine("LEFT");
            }
            else if (prVekt[2] < 0)
            {
                Console.WriteLine("RIGHT");
            }
            else
            {
                Console.WriteLine("TOWARDS");
            }
          /*
            Console.WriteLine(Convert.ToString(prVekt[0]));
            Console.WriteLine(Convert.ToString(prVekt[1]));
            Console.WriteLine(Convert.ToString(prVekt[2]));      */
        }
    }
}


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

namespace Codeforces
{
    class A
    {
        private static ThreadStart s_threadStart = new A().Go;
        private static bool s_time = false;

        private void Go()
        {
            long[] A = new long[] { GetInt(), GetInt() };
            long[] B = new long[] { GetInt(), GetInt() };
            long[] C = new long[] { GetInt(), GetInt() };

            long det = A[0] * B[1] - A[1] * B[0] + A[1] * C[0] - A[0] * C[1] + B[0] * C[1] - B[1] * C[0];
            if (det == 0)
                Wl("TOWARDS");
            else if (det > 0)
                Wl("LEFT");
            else
                Wl("RIGHT");
        }

        #region Template

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            timer.Stop();
            if (s_time)
                Wl(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            while (ioEnum == null || !ioEnum.MoveNext())
            {
                ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
            }

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            if (o is double)
            {
                Wld((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wld((o as float?).Value, "");
            }
            else
                Console.WriteLine(o.ToString());
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            Wl(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wld(double d, string format)
        {
            Wl(d.ToString(format, CultureInfo.InvariantCulture));
        }

        public struct Tuple<T, K> : IComparable<Tuple<T, K>>
            where T : IComparable<T>
            where K : IComparable<K>
        {
            public T Item1;
            public K Item2;

            public Tuple(T t, K k)
            {
                Item1 = t;
                Item2 = k;
            }

            public override bool Equals(object obj)
            {
                var o = (Tuple<T, K>)obj;
                return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);
            }

            public override int GetHashCode()
            {
                return Item1.GetHashCode() ^ Item2.GetHashCode();
            }

            public override string ToString()
            {
                return "(" + Item1 + " " + Item2 + ")";
            }

            #region IComparable<Tuple<T,K>> Members

            public int CompareTo(Tuple<T, K> other)
            {
                int ret = Item1.CompareTo(other.Item1);
                if (ret != 0) return ret;
                return Item2.CompareTo(other.Item2);
            }

            #endregion
        }

        #endregion
    }
}


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

namespace Temp
{
    internal struct PointInt
    {
        public long X;

        public long Y;

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

        public PointInt(PointInt head)
            : this(head.X, head.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 bool IsInsideRectangle(long l, long b, long r, long t)
        {
            return (l <= X) && (X <= r) && (b <= Y) && (Y <= t);
        }
    }

    internal 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 ContainsPoint(PointInt p)
        {
            return A * p.X + B * p.Y + C == 0;
        }
    }

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

        public static long VectInt(PointInt a, PointInt b, PointInt c)
        {
            return (b.X - a.X) * (c.Y - a.Y) - (b.Y - a.Y) * (c.X - a.X);
        }
    }

    internal class MatrixInt
    {
        private 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);
        }
    }

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

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

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

    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 ReadInt(out int int1, out int int2, out int int3, out int int4)
        {
            int[] numbers = new int[4];
            ReadInt(numbers);
            int1 = numbers[0];
            int2 = numbers[1];
            int3 = numbers[2];
            int4 = numbers[3];
        }

        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
            return Console.ReadLine().Select(x => int.Parse(x.ToString())).ToArray();
            // 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]);
            }
        }

        public static void ReadDouble(double[] 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] = double.Parse(list[i]);
            }
        }

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

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

        public static string ReadLine()
        {
            return Console.ReadLine();
        }
    }

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

    internal 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];
        }
    }

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

        private readonly T[] m_Tree;

        private Func<T, T, T> m_Operation;

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

    internal class FenwickTreeInt64
    {
        public FenwickTreeInt64(int size)
        {
            this.m_Size = size;
            m_Tree = new long[size];
        }

        public FenwickTreeInt64(int size, IList<long> tree)
            : this(size)
        {
            for (int i = 0; i < size; i++)
            {
                Inc(i, tree[i]);
            }
        }

        public long Sum(int r)
        {
            long res = 0;
            for (; r >= 0; r = (r & (r + 1)) - 1)
            {
                res += m_Tree[r];
            }
            return res;
        }

        public long Sum(int l, int r)
        {
            return Sum(r) - Sum(l - 1);
        }

        public void Inc(int i, long x)
        {
            for (; i < m_Size; i = i | (i + 1))
            {
                m_Tree[i] += x;
            }
        }

        public void Set(int i, long x)
        {
            Inc(i, x - Sum(i, i));
        }

        private int m_Size;

        private long[] m_Tree;
    }

    internal class AccumulativeDictionary<TKey> : Dictionary<TKey, int>
    {
        public new void Add(TKey key, int value = 1)
        {
            if (this.ContainsKey(key))
            {
                base[key] += value;
            }
            else
            {
                base.Add(key, value);
            }
        }

        public new int this[TKey key]
        {
            get
            {
                return this.ContainsKey(key) ? base[key] : 0;
            }
            set
            {
                this.Add(key, value);
            }
        }
    }

    internal class PriorityQueue<T>
    {
        public PriorityQueue(Comparison<T> comparison = null)
        {
            if (comparison == null)
            {
                if (typeof(T).GetInterfaces().Any(i => i == typeof(IComparable<T>)))
                {
                    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);
            m_Indexes.Add(item, this.Count);
            this.Count++;
            Up(this.Count);
        }

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

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

                Swap(0, this.Count - 1);
                m_Indexes.Remove(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");
        }

        public void Update(T item)
        {
            int index = m_Indexes[item];
            this.Up(index + 1);
        }

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

        private readonly Dictionary<T, int> m_Indexes = new Dictionary<T, int>();

        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;

            m_Indexes[m_List[i]] = i;
            m_Indexes[m_List[j]] = j;
        }
    }

    internal class Program
    {
        private static StreamReader m_InputStream;

        private static StreamWriter m_OutStream;

        private static void OpenFiles()
        {
            m_InputStream = File.OpenText("input.txt");
            Console.SetIn(m_InputStream);

            m_OutStream = File.CreateText("output.txt");
            Console.SetOut(m_OutStream);
        }

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

            m_InputStream.Dispose();
            m_OutStream.Dispose();
        }

        private static void Main()
        {
            //OpenFiles();

            new Solution().Solve();

            //CloseFiles();
        }
    }

    internal class Solution
    {
        public void Solve()
        {
            PointInt[] p = new PointInt[3];
            for (int i = 0; i < 3; i++)
            {
                Reader.ReadLong(out p[i].X, out p[i].Y);
            }

            long res = Geometry.VectInt(p[1], p[0], p[2]);

            if (res == 0)
            {
                Console.WriteLine("TOWARDS");
                return;
            }

            if (res < 0)
            {
                Console.WriteLine("LEFT");
                return;
            }

            Console.WriteLine("RIGHT");
        }
    }
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            long xA, yA, xB, yB, xC, yC;
            string str;
            string[] split = new string [2];
            str = Console.ReadLine();
            split= str.Split();
            xA = Convert.ToInt64(split[0]); yA = Convert.ToInt64(split[1]);
            str = Console.ReadLine();
            split = str.Split();
            xB = Convert.ToInt64(split[0]); yB = Convert.ToInt64(split[1]);
            str = Console.ReadLine();
            split = str.Split();
            xC = Convert.ToInt64(split[0]); yC = Convert.ToInt64(split[1]);

            if ((xB - xA) * (yC - yA) == (xC - xA) * (yB - yA))
                Console.WriteLine("TOWARDS");
            else
                if ((xC - xA) * (yB - yA) - (xB - xA) * (yC - yA) > 0)
                    Console.WriteLine("RIGHT");
                else Console.WriteLine("LEFT");

        }
    }
}


using System;
using System.Linq;
using System.Text;
using System.Collections.Generic;
class Program{
	static void Main() {
		int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int[] b = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
		long[] v1 = new long[2]{b[0] - a[0], b[1] - a[1]};
		long[] v2 = new long[2]{c[0] - b[0], c[1] - b[1]};
		long product = (v1[0] * v2[1]) - (v1[1] * v2[0]);

		if(product == 0)
			Console.WriteLine("TOWARDS");
		else if(product > 0)
			Console.WriteLine("LEFT");
		else
			Console.WriteLine("RIGHT");
	}
}


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

namespace CodeForces
{
    class R140_Div2_A
    {
        static void Main(string[] args)
        {
            string[] s;
            s = (Console.ReadLine().Split());
            long ax = Convert.ToInt64(s[0]);
            long ay = Convert.ToInt64(s[1]);
            s = (Console.ReadLine().Split());
            long bx = Convert.ToInt64(s[0]);
            long by = Convert.ToInt64(s[1]);
            s = (Console.ReadLine().Split());
            long cx = Convert.ToInt64(s[0]);
            long cy = Convert.ToInt64(s[1]);

            long d = (cx - ax) * (by - ay) - (bx - ax) * (cy - ay);
            string ret;
            if (d == 0)
                ret = "TOWARDS";
            else if (d < 0)
                ret = "LEFT";
            else // d > 0
                ret = "RIGHT";
            Console.WriteLine(ret);
        }
    }
}


using System; using System.Linq;

class P {
  static void Main() {
    var a = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
    var b = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
    var c = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
    var a1 = Math.Atan2(b[1]-a[1],b[0]-a[0]);
    var a2 = Math.Atan2(c[1]-b[1],c[0]-b[0]);
    Func<double,double, double> e = (x1,x2) => Math.Abs(x1-x2);
    var eF = e(a1,a2);
    var pi = Math.PI;
    var eR = Math.Min(e(a1,a2+pi/2) , e(a1,a2-1.5*pi));
    var eL = Math.Min(e(a1,a2-pi/2) , e(a1,a2+1.5*pi));
    if (eF < eL && eF < eR) Console.Write("TOWARDS");
    else Console.Write(eL < eR ? "LEFT" : "RIGHT");
  }
}


using System;
class test
{
    static void Main()
    {
        int []a = new int [2];
        int []b = new int [2];
        int []c = new int [2];

        string last = "";
        string last2 = "";

        for(int i=0;i<3;i++)
            {
                string []tmp = Console.ReadLine().Split();
                if(i == 0)
                    {
                        a[0] = int.Parse(tmp[0]);
                        a[1] = int.Parse(tmp[1]);
                    }
                if(i == 1)
                    {
                        b[0] = int.Parse(tmp[0]);
                        b[1] = int.Parse(tmp[1]);
                    }
               if(i == 2)
                    {
                        c[0] = int.Parse(tmp[0]);
                        c[1] = int.Parse(tmp[1]);
                    }
            }

         if(b[1]>a[1]){last += "U";}
         if(b[1]<a[1]){last += "D";}
         if(b[0]>a[0]){last += "R";}
         if(b[0]<a[0]){last += "L";}

         if(c[1]>b[1]){last2 += "U";}
         if(c[1]<b[1]){last2 += "D";}
         if(c[0]>b[0]){last2 += "R";}
         if(c[0]<b[0]){last2 += "L";}

         if(last == last2){Console.WriteLine("TOWARDS");}

         else
             {
                 if(last == "U")
                     {
                         if(last2 == "R"){Console.WriteLine("RIGHT");}
                         if(last2 == "L"){Console.WriteLine("LEFT");}
                     }
                 if(last == "D")
                     {
                         if(last2 == "R"){Console.WriteLine("LEFT");}
                         if(last2 == "L"){Console.WriteLine("RIGHT");}
                     }
                 if(last == "L")
                     {
                         if(last2 == "U"){Console.WriteLine("RIGHT");}
                         if(last2 == "D"){Console.WriteLine("LEFT");}
                     }
                 if(last == "R")
                     {
                         if(last2 == "D"){Console.WriteLine("RIGHT");}
                         if(last2 == "U"){Console.WriteLine("LEFT");}
                     }
                 if(last == "UR")
                     {
                         if(last2 == "UL"){Console.WriteLine("LEFT");}
                         if(last2 == "DR"){Console.WriteLine("RIGHT");}
                     }
                 if(last == "UL")
                     {
                         if(last2 == "UR"){Console.WriteLine("RIGHT");}
                         if(last2 == "DL"){Console.WriteLine("LEFT");}
                     }
                 if(last == "DR")
                     {
                         if(last2 == "UR"){Console.WriteLine("LEFT");}
                         if(last2 == "DL"){Console.WriteLine("RIGHT");}
                     }
                 if(last == "DL")
                     {
                         if(last2 == "UL"){Console.WriteLine("RIGHT");}
                         if(last2 == "DR"){Console.WriteLine("LEFT");}
                     }
             }
    }

}


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

namespace Where_do_I_Turn
{
    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)
        {
            var a = new Point(Next(), Next());
            var b = new Point(Next(), Next());
            var c = new Point(Next(), Next());

            Point ab = Minus(a, b);
            Point bc = Minus(b, c);

            if (Mult(ab, bc) != 0)
                writer.WriteLine("TOWARDS");
            else
            {
                var left = new Point(-ab.y, ab.x);
                if (Mult(left, bc) > 0)
                    writer.WriteLine("LEFT");
                else
                {
                    writer.WriteLine("RIGHT");
                }
            }

            writer.Flush();
        }

        private static long Mult(Point a, Point b)
        {
            return a.x*b.x + a.y*b.y;
        }

        private static Point Minus(Point a, Point b)
        {
            return new Point(b.x - a.x, b.y - a.y);
        }

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

        #region Nested type: Point

        private class Point
        {
            public readonly long x;
            public readonly long y;

            public Point(long x, long y)
            {
                this.x = x;
                this.y = y;
            }
        }

        #endregion
    }
}


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

class Program
{
    static void Main(string[] args)
    {
        double[,] xyz = new double[3, 2];
        string[] input;
        for (int i = 0; i < 3; i++)
        {
            input = Console.ReadLine().Split(' ');
            xyz[i, 0] = double.Parse(input[0]);
            xyz[i, 1] = double.Parse(input[1]);
        }

        for (int i = 1; i < 3; i++)
            for (int j = 0; j < 2; j++)
                xyz[i, j] -= xyz[0, j];
        xyz[0, 0] = xyz[0, 1] = 0;

        double[] c = new double[2];
        c[0] = -1 * xyz[1, 1];
        c[1] = xyz[1, 0];

        if (c[0] * xyz[1, 0] + xyz[1, 1] * c[1] == 0 && c[0] * xyz[2, 0] + c[1] * xyz[2, 1] == 0) { Console.WriteLine("TOWARDS"); return; }
        double fi = 0.0;
        if (xyz[1, 0] >= 0 && xyz[1, 1] > 0)
            fi = Math.Acos(xyz[1, 1] / Math.Pow(xyz[1, 0] * xyz[1, 0] + xyz[1, 1] * xyz[1, 1], 0.5));
        if (xyz[1, 0] > 0 && xyz[1, 1] <= 0)
            fi = Math.PI / 2.0 + Math.Acos(xyz[1, 0] / Math.Pow(xyz[1, 0] * xyz[1, 0] + xyz[1, 1] * xyz[1, 1], 0.5));
        if (xyz[1, 0] <= 0 && xyz[1, 1] < 0)
            fi = Math.PI + Math.Acos(-1 * xyz[1, 1] / Math.Pow(xyz[1, 0] * xyz[1, 0] + xyz[1, 1] * xyz[1, 1], 0.5));
        if (xyz[1, 0] < 0 && xyz[1, 1] >= 0)
            fi = Math.PI * 3.0 / 2.0 + Math.Acos(-1 * xyz[1, 0] / Math.Pow(xyz[1, 0] * xyz[1, 0] + xyz[1, 1] * xyz[1, 1], 0.5));

        double x, y;
        for (int i = 0; i < 3; i++)
        {
            x = xyz[i, 0];
            y = xyz[i, 1];
            xyz[i, 0] = x * Math.Cos(fi) - y * Math.Sin(fi);
            xyz[i, 1] = y * Math.Cos(fi) + x * Math.Sin(fi);
        }

        if (xyz[1, 0] < xyz[2, 0])
            Console.WriteLine("RIGHT");
        if (xyz[1, 0] > xyz[2, 0])
            Console.WriteLine("LEFT");
        Console.ReadLine();
    }
}


using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] start = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));
            int[] pos = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));
            int[] end = Array.ConvertAll(Console.ReadLine().Split(' '), x => int.Parse(x));

            double r = findSide(start[0], start[1], pos[0], pos[1], end[0], end[1]);

            if(r == 0)
                    Console.WriteLine("TOWARDS");
            else if(r < 0)
                    Console.WriteLine("RIGHT");
            else if(r > 0)
                    Console.WriteLine("LEFT");
        }

        public static double findSide(
            double ax, double ay,
            double bx, double by,
            double cx, double cy)
        {
            return ((bx - ax) * (cy - ay) - (by - ay) * (cx - ax));
        }
    }
}


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

namespace _227A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split(' ');
            string[] b = Console.ReadLine().Split(' ');
            string[] c = Console.ReadLine().Split(' ');

            long xa = Convert.ToInt64(a[0]);
            long ya = Convert.ToInt64(a[1]);
            long xb = Convert.ToInt64(b[0]);
            long yb = Convert.ToInt64(b[1]);
            long xc = Convert.ToInt64(c[0]);
            long yc = Convert.ToInt64(c[1]);

            long k = (xb - xa) * (yc - yb) - (xc - xb) * (yb - ya);

            if (k > 0) Console.WriteLine("LEFT");
            else
            {
                if (k == 0) Console.WriteLine("TOWARDS");
                else Console.WriteLine("RIGHT");
            }
            Console.ReadLine();
        }
    }
}


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

namespace Codeforces
{
    class A
    {
        private static ThreadStart s_threadStart = new A().Go;
        private static bool s_time = false;

        private void Go()
        {
            int[] A = new int[] { GetInt(), GetInt() };
            int[] B = new int[] { GetInt(), GetInt() };
            int[] C = new int[] { GetInt(), GetInt() };

            int det = A[0] * B[1] - A[1] * B[0] + A[1] * C[0] - A[0] * C[1] + B[0] * C[1] - B[1] * C[0];
            if (det == 0)
                Wl("TOWARDS");
            else if (det > 0)
                Wl("LEFT");
            else
                Wl("RIGHT");
        }

        #region Template

        public static void Main(string[] args)
        {
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            Thread main = new Thread(new ThreadStart(s_threadStart), 512 * 1024 * 1024);
            timer.Start();
            main.Start();
            main.Join();
            timer.Stop();
            if (s_time)
                Wl(timer.ElapsedMilliseconds);
        }

        private static IEnumerator<string> ioEnum;
        private static string GetString()
        {
            while (ioEnum == null || !ioEnum.MoveNext())
            {
                ioEnum = Console.ReadLine().Split().AsEnumerable().GetEnumerator();
            }

            return ioEnum.Current;
        }

        private static int GetInt()
        {
            return int.Parse(GetString());
        }

        private static long GetLong()
        {
            return long.Parse(GetString());
        }

        private static double GetDouble()
        {
            return double.Parse(GetString());
        }

        private static List<int> GetIntArr(int n)
        {
            List<int> ret = new List<int>(n);
            for (int i = 0; i < n; i++)
            {
                ret.Add(GetInt());
            }
            return ret;
        }

        private static void Wl<T>(T o)
        {
            if (o is double)
            {
                Wld((o as double?).Value, "");
            }
            else if (o is float)
            {
                Wld((o as float?).Value, "");
            }
            else
                Console.WriteLine(o.ToString());
        }

        private static void Wl<T>(IEnumerable<T> enumerable)
        {
            Wl(string.Join(" ", enumerable.Select(e => e.ToString()).ToArray()));
        }

        private static void Wld(double d, string format)
        {
            Wl(d.ToString(format, CultureInfo.InvariantCulture));
        }

        public struct Tuple<T, K> : IComparable<Tuple<T, K>>
            where T : IComparable<T>
            where K : IComparable<K>
        {
            public T Item1;
            public K Item2;

            public Tuple(T t, K k)
            {
                Item1 = t;
                Item2 = k;
            }

            public override bool Equals(object obj)
            {
                var o = (Tuple<T, K>)obj;
                return o.Item1.Equals(Item1) && o.Item2.Equals(Item2);
            }

            public override int GetHashCode()
            {
                return Item1.GetHashCode() ^ Item2.GetHashCode();
            }

            public override string ToString()
            {
                return "(" + Item1 + " " + Item2 + ")";
            }

            #region IComparable<Tuple<T,K>> Members

            public int CompareTo(Tuple<T, K> other)
            {
                int ret = Item1.CompareTo(other.Item1);
                if (ret != 0) return ret;
                return Item2.CompareTo(other.Item2);
            }

            #endregion
        }

        #endregion
    }
}


// Just split the path string and apply the changes.

using System;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        long x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0;
        string buf = Console.ReadLine();
        string[] vals = buf.Split(' ');
        x1 = Convert.ToInt32(vals[0]);
        y1 = Convert.ToInt32(vals[1]);

        buf = Console.ReadLine();
        vals = buf.Split(' ');
        x2 = Convert.ToInt32(vals[0]);
        y2 = Convert.ToInt32(vals[1]);

        buf = Console.ReadLine();
        vals = buf.Split(' ');
        x3 = Convert.ToInt32(vals[0]);
        y3 = Convert.ToInt32(vals[1]);

        int crs = (x2-x1)*(y3-y2)-(y2-y1)*(x3-x2);
        if(crs == 0) {
            Console.WriteLine("TOWARDS");
        }
        else if(crs < 0) {
            Console.WriteLine("RIGHT");
        }
        else if(crs > 0) {
            Console.WriteLine("LEFT");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

public class taskD
{
    public class MyReader
    {
        private TextReader instream;

        public int[] ReadIntArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            int[] a = new int[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = int.Parse(spl[i]);
            return a;
        }

        public long[] ReadLongArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            long[] a = new long[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = long.Parse(spl[i]);
            return a;
        }

        public double[] ReadDoubleArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            double[] a = new double[spl.Length];

            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            for (int i = 0; i < a.Length; i++)
                a[i] = double.Parse(spl[i], nfi);
            return a;
        }

        public int ReadInt()
        {
            return int.Parse(instream.ReadLine());
        }

        public long ReadLong()
        {
            return long.Parse(instream.ReadLine());
        }

        public void SetInStream(TextReader textReader)
        {
            this.instream = textReader;
        }

        internal string ReadLine()
        {
            return instream.ReadLine();
        }
    }

    static void Main(string[] args)
    {
        MyReader instream = new MyReader();
        instream.SetInStream(Console.In);

        TextWriter outstream = Console.Out;

        solve(instream, outstream);

    }

    private static void solve(MyReader instream, TextWriter outstream)
    {
        int[] nmk = instream.ReadIntArray();
        int n = nmk[0];
        int m = nmk[1];
        int k = nmk[2];

        int[] r = new int[n];
        int[] g = new int[n];

        bool rfree = false;
        bool gfree = false;

        for (int i = 0; i < n; i++)
        {
            string line = instream.ReadLine();

            int rpos = -1;
            int gpos = -1;

            int rcnt = 0;
            int gcnt = 0;
            for (int j = 0; j < line.Length; j++)
            {
                if (line[j] == 'R') { rpos = j; rcnt++; }
                if (line[j] == 'G') { gpos = j; gcnt++; }
            }

            if (rpos < 0 && (gpos >= 0 && (gcnt==1 || m>2)))
                gfree = true;
            else if ((rpos >= 0 && (rcnt==1 || m>2)) && gpos < 0)
                rfree = true;
            else
            {
                if (gpos>=0 && rpos>=0 && gpos > rpos)
                {
                    gpos = m - gpos - 1;
                    rpos = m - rpos - 1;
                }
            }
            r[i] = rpos;
            g[i] = gpos;
        }

        if (m == 1)
        {
            outstream.WriteLine("Second");
            return;
        }

        if (rfree && gfree)
        {
            outstream.WriteLine("Draw");
            return;
        }
        if (gfree)
        {
            outstream.WriteLine("First");
            return;
        }
        if (rfree)
        {
            outstream.WriteLine("Second");
            return;
        }

        int odd = 0;
        for (int i = 0; i < n; i++)
        {
            if (r[i] >= 0 && g[i] >= 0)
            {
                int dist = r[i] - g[i] - 1;

                if (dist % 2 == 1) odd++;
            }
        }

        if (odd % (k + 1) != 0)
            outstream.WriteLine("First");
        else
            outstream.WriteLine("Second");
    }

}


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

public class taskD
{
    public class MyReader
    {
        private TextReader instream;

        public int[] ReadIntArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            int[] a = new int[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = int.Parse(spl[i]);
            return a;
        }

        public long[] ReadLongArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            long[] a = new long[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = long.Parse(spl[i]);
            return a;
        }

        public double[] ReadDoubleArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            double[] a = new double[spl.Length];

            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            for (int i = 0; i < a.Length; i++)
                a[i] = double.Parse(spl[i], nfi);
            return a;
        }

        public int ReadInt()
        {
            return int.Parse(instream.ReadLine());
        }

        public long ReadLong()
        {
            return long.Parse(instream.ReadLine());
        }

        public void SetInStream(TextReader textReader)
        {
            this.instream = textReader;
        }

        internal string ReadLine()
        {
            return instream.ReadLine();
        }
    }

    static void Main(string[] args)
    {
        MyReader instream = new MyReader();
        instream.SetInStream(Console.In);

        TextWriter outstream = Console.Out;

        solve(instream, outstream);

    }

    private static void solve(MyReader instream, TextWriter outstream)
    {
        int[] nmk = instream.ReadIntArray();
        int n = nmk[0];
        int m = nmk[1];
        int k = nmk[2];

        int[] r = new int[n];
        int[] g = new int[n];

        bool rfree = false;
        bool gfree = false;

        for (int i = 0; i < n; i++)
        {
            string line = instream.ReadLine();

            int rpos = -1;
            int gpos = -1;
            for (int j = 0; j < line.Length; j++)
            {
                if (line[j] == 'R') rpos = j;
                if (line[j] == 'G') gpos = j;
            }

            if (rpos < 0 && gpos >= 0)
                gfree = true;
            else if (rpos >= 0 && gpos < 0)
                rfree = true;
            else
            {
                if (gpos > rpos)
                {
                    gpos = m - gpos - 1;
                    rpos = m - rpos - 1;
                }
            }
            r[i] = rpos;
            g[i] = gpos;
        }

        if (m == 1)
        {
            outstream.WriteLine("Second");
            return;
        }

        if (rfree && gfree)
        {
            outstream.WriteLine("Draw");
            return;
        }
        if (gfree)
        {
            outstream.WriteLine("First");
            return;
        }
        if (rfree)
        {
            outstream.WriteLine("Second");
            return;
        }

        int odd = 0;
        for (int i = 0; i < n; i++)
        {
            if (r[i] >= 0 && g[i] >= 0)
            {
                int dist = r[i] - g[i] - 1;

                if (dist % 2 == 1) odd++;
            }
        }

        if (odd % (k + 1) != 0)
            outstream.WriteLine("First");
        else
            outstream.WriteLine("Second");
    }

}


using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

public class taskD
{
    public class MyReader
    {
        private TextReader instream;

        public int[] ReadIntArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            int[] a = new int[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = int.Parse(spl[i]);
            return a;
        }

        public long[] ReadLongArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            long[] a = new long[spl.Length];
            for (int i = 0; i < a.Length; i++)
                a[i] = long.Parse(spl[i]);
            return a;
        }

        public double[] ReadDoubleArray()
        {
            string inp = instream.ReadLine().Trim();
            string[] spl = inp.Split(' ');

            double[] a = new double[spl.Length];

            System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            for (int i = 0; i < a.Length; i++)
                a[i] = double.Parse(spl[i], nfi);
            return a;
        }

        public int ReadInt()
        {
            return int.Parse(instream.ReadLine());
        }

        public long ReadLong()
        {
            return long.Parse(instream.ReadLine());
        }

        public void SetInStream(TextReader textReader)
        {
            this.instream = textReader;
        }

        internal string ReadLine()
        {
            return instream.ReadLine();
        }
    }

    static void Main(string[] args)
    {
        MyReader instream = new MyReader();
        instream.SetInStream(Console.In);

        TextWriter outstream = Console.Out;

        solve(instream, outstream);

    }

    private static void solve(MyReader instream, TextWriter outstream)
    {

        int[] nmk = instream.ReadIntArray();
        int n = nmk[0];
        int m = nmk[1];
        int k = nmk[2];

        int[] r = new int[n];
        int[] g = new int[n];

        bool rfree = false;
        bool gfree = false;

        for (int i = 0; i < n; i++)
        {
            string line = instream.ReadLine();

            int rpos = -1;
            int gpos = -1;

            int rcnt = 0;
            int gcnt = 0;
            for (int j = 0; j < line.Length; j++)
            {
                if (line[j] == 'R') { rpos = j; rcnt++; }
                if (line[j] == 'G') { gpos = j; gcnt++; }
            }

            if (rpos < 0 && (gpos >= 0 && (gcnt==1 || m>2)))
                gfree = true;
            else if ((rpos >= 0 && (rcnt==1 || m>2)) && gpos < 0)
                rfree = true;
            else
            {
                if (gpos>=0 && rpos>=0 && gpos > rpos)
                {
                    gpos = m - gpos - 1;
                    rpos = m - rpos - 1;
                }
            }
            r[i] = rpos;
            g[i] = gpos;
        }

        if (m == 1)
        {
            outstream.WriteLine("Second");
            return;
        }

        if (rfree && gfree)
        {
            outstream.WriteLine("Draw");
            return;
        }
        if (gfree)
        {
            outstream.WriteLine("First");
            return;
        }
        if (rfree)
        {
            outstream.WriteLine("Second");
            return;
        }

        for (int test = 0; test < 7; test++)
        {
            int odd = 0;
            for (int i = 0; i < n; i++)
            {
                if (r[i] >= 0 && g[i] >= 0)
                {
                    int dist = r[i] - g[i] - 1;

                    if ((dist>>test) % 2 == 1) odd++;
                }
            }

            if (odd % (k + 1) != 0)
            {
                outstream.WriteLine("First");
                return;
            }

        }
            outstream.WriteLine("Second");
    }

}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    class Edge<T>
    {
        public int To, Inv;
        public T Capacity;
        public Edge(int to, int inv, T capacity)
        {
            To = to;
            Inv = inv;
            Capacity = capacity;
        }
    }

    static void AddEdge<T>(List<Edge<T>>[] g, int from, int to, T capacity, bool directed = true)
    {
        g[from].Add(new Edge<T>(to, g[to].Count, capacity));
        g[to].Add(new Edge<T>(from, g[from].Count - 1, directed ? default(T) : capacity));
    }

    static class Flow
    {
        private static int[] level;
        private static int[] ptr;
        private static int n, source, sink;
        private static List<Edge<long>>[] g;

        public static long Find(List<Edge<long>>[] g, int source, int sink)
        {
            n = g.Length;
            level = new int[n];
            ptr = new int[n];
            Flow.g = g;
            Flow.source = source;
            Flow.sink = sink;

            long ret = 0;
            while (true)
            {
                Bfs();
                if (level[sink] < 0)
                    return ret;
                Array.Clear(ptr, 0, n);
                long f;
                while ((f = Dfs(source, int.MaxValue / 2)) > 0)
                    ret += f;
            }
        }

        static void Bfs()
        {
            for (int i = 0; i < n; i++)
                level[i] = -1;
            var q = new Queue<int>();
            level[source] = 0;
            q.Enqueue(source);
            while (q.Count > 0)
            {
                var v = q.Dequeue();
                foreach (var e in g[v])
                    if (e.Capacity > 0 && level[e.To] < 0)
                    {
                        level[e.To] = level[v] + 1;
                        q.Enqueue(e.To);
                    }
            }
        }

        static long Dfs(int v, long f)
        {
            if (v == sink)
                return f;
            for (; ptr[v] < g[v].Count; ptr[v]++)
            {
                var e = g[v][ptr[v]];
                if (e.Capacity <= 0 || level[v] >= level[e.To])
                    continue;
                long d = Dfs(e.To, Math.Min(f, e.Capacity));
                if (d <= 0)
                    continue;
                e.Capacity -= d;
                g[e.To][e.Inv].Capacity += d;
                return d;
            }
            return 0;
        }
    }

    public void Solve()
    {
        for (int tt = ReadInt(); tt > 0; tt--)
        {
            int n = ReadInt();
            var a = ReadIntArray();
            var b = ReadIntArray();

            long ans = 1L * Math.Min(a[0], b[1]) + Math.Min(a[1], b[2]) + Math.Min(a[2], b[0]);
            var g = Init<List<Edge<long>>>(8);
            for (int i = 0; i < 3; i++)
            {
                AddEdge(g, 6, i, a[i]);
                AddEdge(g, i + 3, 7, b[i]);
                for (int j = 0; j < 2; j++)
                    AddEdge(g, i, (i + 2 + j) % 3 + 3, long.MaxValue);
            }

            Write(a.Sum(aa => (long)aa) - Flow.Find(g, 6, 7), ans);
        }
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }
        return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array) writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class E
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Read();
		var b = Read();

		var max = Min(a[0], b[1]) + Min(a[1], b[2]) + Min(a[2], b[0]);

		var dg = new List<long[]>();
		var sv = 6;
		var ev = 7;
		for (long i = 0; i < 3; i++)
		{
			dg.Add(new[] { sv, i, a[i] });
			dg.Add(new[] { 3 + i, ev, b[i] });
		}
		dg.Add(new[] { 0L, 3, Min(a[0], b[0]) });
		dg.Add(new[] { 1L, 4, Min(a[1], b[1]) });
		dg.Add(new[] { 2L, 5, Min(a[2], b[2]) });
		dg.Add(new[] { 0L, 5, Min(a[0], b[2]) });
		dg.Add(new[] { 1L, 3, Min(a[1], b[0]) });
		dg.Add(new[] { 2L, 4, Min(a[2], b[1]) });

		var min = n - MaxFlow(ev, sv, ev, dg.ToArray());
		Console.WriteLine($"{min} {max}");
	}

	// dg: { from, to, capacity }
	static long MaxFlow(int n, int sv, int ev, long[][] dg)
	{
		var map = Array.ConvertAll(new int[n + 1], _ => new List<long[]>());
		foreach (var e in dg)
		{
			map[e[0]].Add(new[] { e[0], e[1], e[2], map[e[1]].Count });
			map[e[1]].Add(new[] { e[1], e[0], 0, map[e[0]].Count - 1 });
		}

		long Bfs()
		{
			var from = new long[n + 1][];
			var minFlow = new long[n + 1];
			Array.Fill(minFlow, long.MaxValue);
			var q = new Queue<long>();
			q.Enqueue(sv);

			while (q.TryDequeue(out var v))
			{
				if (v == ev) break;
				foreach (var e in map[v])
				{
					if (from[e[1]] != null || e[2] == 0) continue;
					from[e[1]] = e;
					minFlow[e[1]] = Math.Min(minFlow[v], e[2]);
					q.Enqueue(e[1]);
				}
			}

			if (from[ev] == null) return 0;
			for (long v = ev; v != sv; v = from[v][0])
			{
				var e = from[v];
				e[2] -= minFlow[ev];
				map[e[1]][(int)e[3]][2] += minFlow[ev];
			}
			return minFlow[ev];
		}

		long M = 0, t;
		while ((t = Bfs()) > 0) M += t;
		return M;
	}
}


using System;

namespace CodeForces.ProblemE
{
    class Program
    {
        /*
        319
        10 53 256
        182 103 34

        119 226
         */
        static void Main(string[] args)
        {
            int maxWin = 0;
            int minWin = 0;
            int rounds = int.Parse(Console.ReadLine());
            string[] patternAnya = Console.ReadLine().Split(' ');
            string[] patternBorya = Console.ReadLine().Split(' ');
            Player anya = new Player(patternAnya);
            Player borya = new Player(patternBorya);

            if (anya.Rock >= borya.Scissor)
                maxWin += borya.Scissor;
            else
                maxWin += anya.Rock;

            if (anya.Scissor >= borya.Paper)
                maxWin += borya.Paper;
            else
                maxWin += anya.Scissor;

            if (anya.Paper >= borya.Rock)
                maxWin += borya.Rock;
            else
                maxWin += anya.Paper;

            if (anya.Rock > borya.Paper + borya.Rock && borya.Scissor != 0)
                if (anya.Rock - (borya.Paper + borya.Rock) < borya.Scissor)
                    minWin += anya.Rock - borya.Paper - borya.Rock;
                else
                    minWin += borya.Scissor;

            if (anya.Scissor > borya.Rock + borya.Scissor && borya.Paper != 0)
                if (anya.Scissor - (borya.Rock + borya.Scissor) < borya.Paper)
                    minWin += anya.Scissor - borya.Rock - borya.Scissor;
                else
                    minWin += borya.Paper;

            if (anya.Paper > borya.Scissor + borya.Paper && borya.Rock != 0)
                if (anya.Paper - (borya.Scissor + borya.Paper) < borya.Rock)
                    minWin += anya.Paper - borya.Scissor - borya.Paper;
                else
                    minWin += borya.Rock;

            Console.WriteLine(minWin);
            Console.WriteLine(maxWin);
        }

        public struct Player
        {
            public int Rock;
            public int Paper;
            public int Scissor;

            public Player(string[] pattern)
            {
                Rock = int.Parse(pattern[0]);
                Scissor = int.Parse(pattern[1]);
                Paper = int.Parse(pattern[2]);
            }
        }
    }
}


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

namespace _1426E
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] alice = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int[] Bob = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            //most wins
            int mostWins = 0;
            mostWins += Math.Min(alice[0], Bob[1]);
            mostWins += Math.Min(alice[1], Bob[2]);
            mostWins += Math.Min(alice[2], Bob[0]);

            //least wins
            List<int[]> aliceDistribution = new List<int[]>()
            { new int[3] { 0, 0, 0 }, new int[3] { 0, 0, 0 }, new int[3] { 0, 0, 0 } };

            for (int a = 0; a < alice.Length; a++)
            {
                for (int b = 0; b < Bob.Length; b++)
                {
                    if ((a + b) % alice.Length == (a + 1) % alice.Length)
                        continue;
                    int c = Math.Min(Bob[(a + b) % alice.Length], alice[a]);
                    alice[a] -= c;
                    Bob[(a + b) % alice.Length] -= c;
                    aliceDistribution[a][(a + b) % alice.Length] += c;
                }

                if (alice[a] > 0)
                {
                    for (int a2 = 0; a2 < alice.Length; a2++)
                    {
                        if (a2 == a)
                            continue;
                        for (int ad = 0; ad < aliceDistribution.Count; ad++)
                        {
                            if (ad == (a + 1) % alice.Length)
                                continue;

                            int c = Math.Min(alice[a], aliceDistribution[a2][ad]);
                            alice[a] -= c;
                            aliceDistribution[a2][ad] -= c;
                            aliceDistribution[a2][(a + 1) % alice.Length] += c;
                        }
                    }
                }
            }

            int leastWins = 0;
            foreach (var item in alice)
                leastWins += item;

            Console.WriteLine(leastWins + " " + mostWins);
        }
    }
}


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

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    class Edge<T>
    {
        public int To, Inv;
        public T Capacity;
        public Edge(int to, int inv, T capacity)
        {
            To = to;
            Inv = inv;
            Capacity = capacity;
        }
    }

    static void AddEdge<T>(List<Edge<T>>[] g, int from, int to, T capacity, bool directed = true)
    {
        g[from].Add(new Edge<T>(to, g[to].Count, capacity));
        g[to].Add(new Edge<T>(from, g[from].Count - 1, directed ? default(T) : capacity));
    }

    static class Flow
    {
        private static int[] level;
        private static int[] ptr;
        private static int n, source, sink;
        private static List<Edge<long>>[] g;

        public static long Find(List<Edge<long>>[] g, int source, int sink)
        {
            n = g.Length;
            level = new int[n];
            ptr = new int[n];
            Flow.g = g;
            Flow.source = source;
            Flow.sink = sink;

            long ret = 0;
            while (true)
            {
                Bfs();
                if (level[sink] < 0)
                    return ret;
                Array.Clear(ptr, 0, n);
                long f;
                while ((f = Dfs(source, int.MaxValue / 2)) > 0)
                    ret += f;
            }
        }

        static void Bfs()
        {
            for (int i = 0; i < n; i++)
                level[i] = -1;
            var q = new Queue<int>();
            level[source] = 0;
            q.Enqueue(source);
            while (q.Count > 0)
            {
                var v = q.Dequeue();
                foreach (var e in g[v])
                    if (e.Capacity > 0 && level[e.To] < 0)
                    {
                        level[e.To] = level[v] + 1;
                        q.Enqueue(e.To);
                    }
            }
        }

        static long Dfs(int v, long f)
        {
            if (v == sink)
                return f;
            for (; ptr[v] < g[v].Count; ptr[v]++)
            {
                var e = g[v][ptr[v]];
                if (e.Capacity <= 0 || level[v] >= level[e.To])
                    continue;
                long d = Dfs(e.To, Math.Min(f, e.Capacity));
                if (d <= 0)
                    continue;
                e.Capacity -= d;
                g[e.To][e.Inv].Capacity += d;
                return d;
            }
            return 0;
        }
    }

    public void Solve()
    {
        for (int tt = 1; tt > 0; tt--)
        {
            int n = ReadInt();
            var a = ReadIntArray();
            var b = ReadIntArray();

            long ans = 1L * Math.Min(a[0], b[1]) + Math.Min(a[1], b[2]) + Math.Min(a[2], b[0]);
            var g = Init<List<Edge<long>>>(8);
            for (int i = 0; i < 3; i++)
            {
                AddEdge(g, 6, i, a[i]);
                AddEdge(g, i + 3, 7, b[i]);
                for (int j = 0; j < 2; j++)
                    AddEdge(g, i, (i + 2 + j) % 3 + 3, long.MaxValue);
            }

            Write(a.Sum(aa => (long)aa) - Flow.Find(g, 6, 7), ans);
        }
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }
        return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array) writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.Codeforces._1426
{
    class E
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] arrayA = ReadInts();
            int[] arrayB = ReadInts();

            int[][] pats = new int[6][];
            pats[0] = new int[3] { 0, 1, 2 };
            pats[1] = new int[3] { 0, 2, 1 };
            pats[2] = new int[3] { 1, 0, 2 };
            pats[3] = new int[3] { 1, 2, 0 };
            pats[4] = new int[3] { 2, 0, 1 };
            pats[5] = new int[3] { 2, 1, 0 };

            int min = int.MaxValue;
            int max = 0;
            for(int i = 0; i < 6; i++)
            {
                for(int j = 0; j < 6; j++)
                {
                    int cnt = 0;
                    int[] tmpA = new int[3] { arrayA[0], arrayA[1], arrayA[2] };
                    int[] tmpB = new int[3] { arrayB[0], arrayB[1], arrayB[2] };
                    for (int x = 0; x < 3; x++)
                    {
                        for(int y = 0; y < 3; y++)
                        {
                            int common = Min(tmpA[pats[i][x]], tmpB[pats[j][y]]);
                            tmpA[pats[i][x]] -= common;
                            tmpB[pats[j][y]] -= common;
                            if ((pats[i][x] + 1) % 3 == pats[j][y])
                            {
                                cnt += common;
                            }
                        }
                    }
                    min = Min(min, cnt);
                    max = Max(max, cnt);
                }
            }

            /*
            int min = 0;
            {
                int[] tmpA = new int[3] { arrayA[0], arrayA[1], arrayA[2] };
                int[] tmpB = new int[3] { arrayB[0], arrayB[1], arrayB[2] };
                for(int i = 0; i < 3; i++)
                {
                    int common = Min(tmpA[i], tmpB[(i + 2) % 3]);
                    tmpA[i] -= common;
                    tmpB[(i + 2) % 3] -= common;
                }
                for(int i = 0; i < 3; i++)
                {
                    int common = Min(tmpA[i], tmpB[i]);
                    tmpA[i] -= common;
                    tmpB[i] -= common;
                }
                for(int i = 0; i < 3; i++)
                {
                    min += tmpA[i];
                }
            }

            int max = 0;
            {
                for (int i = 0; i < 3; i++)
                {
                    max+= Min(arrayA[i], arrayB[(i +1) % 3]);
                }
            }
            */

            WriteLine(min + " " + max);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

namespace Rock__Paper__Scissors
{
    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)
        {
            Solve();
            writer.Flush();
        }

        private static void Solve()
        {
            int n = Next();
            var a = new[] {Next(), Next(), Next()};
            var b = new[] {Next(), Next(), Next()};

            int min = Math.Max(0, a[0] - b[0] - b[2]) + Math.Max(0, a[1] - b[1] - b[0]) + Math.Max(0, a[2] - b[1] - b[2]);

            int max = Math.Min(a[0], b[1]) + Math.Min(a[1], b[2]) + Math.Min(a[2], b[0]);

            writer.Write(min);
            writer.Write(' ');
            writer.WriteLine(max);
        }

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