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

namespace CodeForces800
{
    internal static class Program
    {
        public static SitComparer cmp = new SitComparer();
        public static void Main()
        {
            // var strrep = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToList();
            // var rep = strrep[0];
            var str = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            var p1 = str[0];
            var t1 = str[1];
            str = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            var p2 = str[0];
            var t2 = str[1];
            str = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            var h = str[0];
            var s = str[1];
            var par1 = 2000;
            var par2 = 700;
            var isOK = true;
            while (isOK)
            {
                isOK = false;
                par1 = par1 * 9 / 10;
                par2 = par2 * 9 / 10;
                var situation = new Situation(0, t1, t2, h);
                var sits = new List<Situation>();
                sits.Add(situation);
                long best_t = long.MaxValue;

                var worstspeed = (p1 - s) * 1.0 / t1 + (p2 - s) * 1.0 / t2;
                while (sits[0].t < best_t)
                {
                    var sit = sits[0];

                    if (sit.h <= 0)
                    {
                        if(44665791077502 != sit.t)
                            isOK = false;
                        Console.WriteLine(sit.t);
                        break;
                    }
                    if (sit.t1 < sit.t2)
                    {
                        TryInsert(sits, new Situation(sit.t + sit.t1, t1, Math.Max(0, sit.t2 - sit.t1), sit.h - (p1 - s)));
                        TryInsert(sits, new Situation(sit.t + sit.t2, t1, t2, sit.h - (p1 + p2 - s)));
                    }

                    if (sit.t1 > sit.t2)
                    {
                        TryInsert(sits, new Situation(sit.t + sit.t2, Math.Max(0, sit.t1 - sit.t2), t2, sit.h - (p2 - s)));
                        TryInsert(sits, new Situation(sit.t + sit.t1, t1, t2, sit.h - (p1 + p2 - s)));
                    }

                    if (sit.t1 == sit.t2)
                    {
                        TryInsert(sits, new Situation(sit.t + sit.t1, t1, t2, sit.h - (p1 + p2 - s)));
                    }
                    sits.RemoveAt(0);
                    if (sits.Count > par1)
                    {
                        var newlist = sits.DistinctBy(x => (x.h, x.t2, x.t1, x.t)).OrderBy(x => (x.t + (x.h - p1 - p2) / worstspeed)).ToList();
                        sits = newlist.Take(Math.Min(par2, newlist.Count)).ToList();
                        sits = sits.OrderBy(x => x.t).ToList();
                    }
                }
                //Console.WriteLine(par1);
                //Console.WriteLine(par2);
            }
        }
        public static void TryInsert(List<Situation> list, Situation situation)
        {
            int index = list.BinarySearch(situation, cmp);// => -4
            if(index < 0)
                index = ~index;
            if (index == 0)
                index++;
            list.Insert(index, situation);

        }
    }

    public class Situation
    {
        public long t;
        public long t1;
        public long t2;
        public long h;

        public Situation(long t, long t1, long t2, long h)
        {
            this.t = t;
            this.h = h;
            this.t1 = t1;
            this.t2 = t2;
        }
    }

    public class SitComparer : IComparer<Situation>
    {
        public int Compare(Situation x, Situation y)
        {
            if (x == null)
            {
                if (y == null)
                {
                    // If x is null and y is null, they're
                    // equal.
                    return 0;
                }
                else
                {
                    // If x is null and y is not null, y
                    // is greater.
                    return -1;
                }
            }
            else
            {
                // If x is not null...
                //
                if (y == null)
                // ...and y is null, x is greater.
                {
                    return 1;
                }
                else
                {
                    // ...and y is not null, compare the
                    // lengths of the two strings.
                    //
                    int retval = x.t.CompareTo(y.t);

                    if (retval != 0)
                    {
                        // If the strings are not of equal length,
                        // the longer string is greater.
                        //
                        return retval;
                    }
                    else
                    {
                        return x.h.CompareTo(y.h);
                    }
                }
            }
        }
    }
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	long gcd(long a, long b){ return a == 0 ? b : gcd(b % a, a);}
	public void Solve(){
try{
checked{

		long mo = N * K;
		List<long> X = new List<long>(){
			A, (mo - A) % mo
		};
		long ma = -1, mi = (long) 1e18;
		foreach(var s in X){
			for(int i=0;i<N;i++){
				long bb = i * K;
				for(int j=-1;j<=1;j+=2){
					long b = (bb + j * B) % mo;
					long l = b - s;
					if(l < 0){
						l %= mo;
						l += mo;
					}
					if(l == 0){
						l = mo;
					}
//Console.WriteLine("s:{0}, l:{1}, mo:{2}, gcd:{3}",s, l, mo, gcd(mo, l));
					//var lcm = mo / gcd(mo, l) * l;
//Console.WriteLine("lcm:{0}, l:{1}",lcm, l);
					//var rr = lcm / l;
					var rr = mo / gcd(mo, l);
					ma = Math.Max(ma, rr);
					mi = Math.Min(mi, rr);
				}
			}
		}
		Console.WriteLine("{0} {1}",mi, ma);
}
} catch (Exception e){
	Console.WriteLine(e);
	return;
}

	}
	long N,K;
	long A,B;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
		d = ria();
		A = d[0]; B = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

namespace ConsoleApplication1
{
    class Program : ProgramBase
    {
        static void Main(string[] args)
        {
            var p = new Program();
            var x = p.Get();
            p.Out(x);
        }

        object Get()
        {
            FileName = "";
            checked
            {
                var n = ReadLong();
                var divisors = new List<long>();
                while (n != 1) {
                    var broken = false;
                    for (long i = 2; i <= Math.Sqrt(n); i++)
                    {
                        if (n % i == 0)
                        {
                            divisors.Add(i);
                            n = n / i;
                            broken = true;
                            break;
                        }
                    }
                    if (!broken)
                    {
                        divisors.Add(n);
                        break;
                    }
                }
                divisors.Sort();
                return divisors.Distinct().Aggregate(1L, (a, x) => a * x);
            }
        }
        public char Diff(char a, char b) {
            if (a != 'a' && b != 'a')
                return 'a';
            if (a != 'b' && b != 'b')
                return 'b';
            return 'c';
        }
        public int[] GetPrimes(int n)
        {
            var sieve = new bool[n + 1];
            var result = new List<int>();
            for (int i = 2; i <= n; i++)
            {
                if (!sieve[i])
                    result.Add(i);
                for (int j = i; j <= n; j += i)
                    sieve[j] = true;
            }

            return result.ToArray();
        }

        public IEnumerable<List<int>> GetAllSubsets(int n, int remaining, int current, List<int> prefix)
        {
            if (remaining == 0)
                return new [] { new List<int>(prefix) };
            if (current == n)
                return new List<int>[0];

            var result = GetAllSubsets(n, remaining, current + 1, prefix);
            prefix.Add(current);
            var res = GetAllSubsets(n, remaining - 1, current + 1, prefix);
            prefix.Remove(current);
            return result.Union(res);
        }

        public int DFS(List<int>[] edges, int[] cats, int catsCount, int currentV, int previousCats, int? parentV)
        {
            var es = edges[currentV];
            var currentCats = (cats[currentV] == 0) ? 0 : previousCats + 1;
            if (currentCats > catsCount)
                return 0;
            if (parentV.HasValue && es.Count == 1)
                return 1;

            var result = 0;
            for (int i = 0; i < es.Count; i++)
                if (!parentV.HasValue || parentV != es[i])
                    result += DFS(edges, cats, catsCount, es[i], currentCats, currentV);
            return result;
        }

        public long BinarySearch(Func<long, double> f, int P, long left, long right)
        {
            if (left == right || right - left == 1)
                return right;

            var centre = (right + left) / 2;

            if (f(centre) >= P)
                return BinarySearch(f, P, left, centre);
            else
                return BinarySearch(f, P, centre, right);
        }
    }
    abstract class ProgramBase
    {
        bool? prod = null;
        StreamReader f;
        protected string FileName { private get; set; }

        protected string Read()
        {
            if (string.IsNullOrEmpty(FileName))
                return Console.ReadLine();
            if (f == null)
                f = new StreamReader((GetProd() ? "" : "c:\\dev\\") + FileName + ".in");
            return f.ReadLine();
        }

        protected int ReadInt()
        {
            return Convert.ToInt32(Read());
        }
        protected int[] ReadInts()
        {
            return Read().Split(' ').Select(x => Convert.ToInt32(x)).ToArray();
        }

        protected long ReadLong()
        {
            return Convert.ToInt64(Read());
        }

        protected long[] ReadLongs()
        {
            return Read().Split(' ').Select(x => Convert.ToInt64(x)).ToArray();
        }

        public void Out(object r)
        {
            if (string.IsNullOrEmpty(FileName))
                Console.WriteLine(r);
            else if (GetProd())
                File.WriteAllText(FileName + ".out", r.ToString());
            else
                Console.WriteLine(r);
        }

        private bool GetProd()
        {
            if (!prod.HasValue)
                try
                {
                    prod = Environment.MachineName != "RENADEEN-NB-W7";
                }
                catch (Exception)
                {
                    prod = true;
                }
            return prod.Value;
        }
        public class DSU
        {
            public int[] arr;
            private Random rand = new Random();
            public DSU(int n)
            {
                arr = new int[n];
                for (int i = 0; i < n; i++)
                {
                    arr[i] = i;
                }
            }
            public void Union(int x, int y)
            {
                var x1 = Root(x);
                var y1 = Root(y);
                if (rand.NextDouble() > 0.5)
                    arr[x1] = y1;
                else
                    arr[y1] = x1;
            }

            public int Root(int x)
            {
                if (arr[x] == x)
                    return x;
                return Root(arr[x]);
            }
            public bool Find(int x, int y)
            { return Root(x) == Root(y); }
        }
    }

    public static class Huj
    {
        public static T MinBy<T>(this IEnumerable<T> source, Func<T, double> func) where T : class
        {
            T result = null;
            var min = double.MaxValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (min > current)
                {
                    min = current;
                    result = item;
                }
            }
            return result;
        }

        public static T MaxBy<T>(this IEnumerable<T> source, Func<T, double> func)
        {
            T result = default(T);
            var max = double.MinValue;
            foreach (var item in source)
            {
                var current = func(item);
                if (max < current)
                {
                    max = current;
                    result = item;
                }
            }
            return result;
        }

        public static string JoinStrings(this IEnumerable<string> source, string delimeter)
        {
            return string.Join(delimeter, source.ToArray());
        }
    }
}


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

namespace ReadWriteTemplate
{
    public static class Solver
    {
        private static void SolveCase()
        {
            const long MOD = 998244353;

            var ntt = new NTT(MOD);

            int n = ReadInt();
            int k = ReadInt();
            int[] d = ReadIntArray();

            int m = 1;
            int p = 0;
            while (m < 5 * n)
            {
                m <<= 1;
                p++;
            }

            long[] a = new long[m];
            for (int i = 0; i < k; i++)
            {
                a[d[i]] = 1;
            }

            ntt.FFT(a, p, false);

            for (int i = 0; i < m; i++)
            {
                a[i] = ntt.Pow(a[i], n / 2);
            }

            ntt.FFT(a, p, true);

            long invM = ntt.Pow(m, MOD - 2);

            long ans = 0;
            for (int i = 0; i < a.Length; i++)
            {
                long c = a[i] * invM % MOD;
                ans = (ans + c * c) % MOD;
            }

            Writer.WriteLine(ans);
        }

        public class NTT
        {
            private readonly long MOD;

            private int maxBase;

            private long[] roots;

            private long[] invRoots;

            public NTT(long mod)
            {
                MOD = mod;

                long tmp = mod - 1;
                maxBase = 0;
                while (tmp % 2 == 0)
                {
                    maxBase++;
                    tmp /= 2;
                }

                long baseRoot = 2;
                while (true)
                {
                    if (Pow(baseRoot, 1 << maxBase) == 1)
                    {
                        if (Pow(baseRoot, 1 << (maxBase - 1)) != 1)
                        {
                            break;
                        }
                    }
                    baseRoot++;
                }

                roots = new long[maxBase];
                roots[0] = baseRoot;
                for (int i = 1; i < maxBase; i++)
                {
                    roots[i] = (roots[i - 1] * roots[i - 1]) % MOD;
                }
                invRoots = new long[maxBase];
                for (int i = 0; i < maxBase; i++)
                {
                    invRoots[i] = Pow(roots[i], mod - 2);
                }
            }

            public long[] Multiply(long[] a, long[] b)
            {
                int n = 1;
                int p = 0;
                while (n < Math.Max(a.Length, b.Length))
                {
                    n <<= 1;
                    p++;
                }
                n <<= 1;
                p++;

                if (p > maxBase)
                {
                    throw new InvalidOperationException($"Mod {MOD} cannot be used ({p} > {maxBase}).");
                }

                var fa = new long[n];
                Array.Copy(a, fa, a.Length);
                var fb = new long[n];
                Array.Copy(b, fb, b.Length);

                FFT(fa, p, false);
                FFT(fb, p, false);

                for (int i = 0; i < n; i++)
                {
                    fa[i] = fa[i] * fb[i] % MOD;
                }

                FFT(fa, p, true);
                long invN = Pow(n, MOD - 2);
                for (int i = 0; i < n; i++)
                {
                    fa[i] = fa[i] * invN % MOD;
                }
                return fa;
            }

            public void FFT(long[] a, int p, bool invert)
            {
                int n = a.Length;
                if (n == 1)
                {
                    return;
                }

                var a0 = new long[n / 2];
                var a1 = new long[n / 2];
                for (int i = 0; i < n / 2; i++)
                {
                    a0[i] = a[2 * i];
                    a1[i] = a[2 * i + 1];
                }
                FFT(a0, p - 1, invert);
                FFT(a1, p - 1, invert);

                long w = 1;
                long wn = invert ? invRoots[maxBase - p] : roots[maxBase - p];

                for (int i = 0; i < n / 2; i++)
                {
                    long d = w * a1[i] % MOD;
                    a[i] = a0[i] + d;
                    if (a[i] >= MOD)
                    {
                        a[i] -= MOD;
                    }
                    a[i + n / 2] = a0[i] - d;
                    if (a[i + n / 2] < 0)
                    {
                        a[i + n / 2] += MOD;
                    }
                    w = w * wn % MOD;
                }
            }

            public long Pow(long a, long n)
            {
                long result = 1;

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

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

                return result;
            }
        }

        public static void Solve()
        {
            // var sw = Stopwatch.StartNew();

            SolveCase();

            /*int T = ReadInt();
            for (int i = 0; i < T; i++)
            {
                // Writer.WriteLine("Case {0}:", i + 1);
                // Writer.Write("Case #{0}: ", i + 1);
                SolveCase();
            }*/

            // sw.Stop();
            // Console.WriteLine(sw.ElapsedMilliseconds);
        }

        public static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

#if DEBUG
            // Reader = Console.In; Writer = Console.Out;
            Reader = File.OpenText("input.txt"); Writer = File.CreateText("output.txt");
#else
            Reader = Console.In; Writer = Console.Out;
#endif

            // Solve();
            Thread thread = new Thread(Solve, 64 * 1024 * 1024);
            thread.CurrentCulture = CultureInfo.InvariantCulture;
            thread.Start();
            thread.Join();

            Reader.Close();
            Writer.Close();
        }

        public static IOrderedEnumerable<TSource> OrderByWithShuffle<TSource, TKey>(this IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
        {
            return source.Shuffle().OrderBy(keySelector);
        }

        public static T[] Shuffle<T>(this IEnumerable<T> source)
        {
            T[] result = source.ToArray();
            Random rnd = new Random();
            for (int i = result.Length - 1; i >= 1; i--)
            {
                int k = rnd.Next(i + 1);
                T tmp = result[k];
                result[k] = result[i];
                result[i] = tmp;
            }
            return result;
        }

        #region Read/Write

        private static TextReader Reader;

        private static TextWriter Writer;

        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 string ReadLine()
        {
            return Reader.ReadLine();
        }

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

        #endregion
    }
}


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

namespace _95D2C
{
    class Program
    {
        static void Main(string[] args)
        {
            var temp = Console.ReadLine().Split(' ');
            ulong n = ulong.Parse(temp[0]);
            ulong m = ulong.Parse(temp[1]);
            ulong t = ulong.Parse(temp[2]);
            ulong sum = 0;
            for (ulong i = 4; i <= n; i++)
            {
                for (ulong j = 1;  j <=m; j++)
                {
                    if (i + j == t)
                    {
                       // ulong res1=0;
                        decimal res1 = 0;
                        if ((Math.Max(n - i + 1, i + 1) < 18)&&(n>=28))
                        {
                           // res1 = (fact(n, 18) )/ fact(Math.Min(i, n - i), 2);
                            res1 = ((decimal)fact(n, 18)) / fact(Math.Min(i, n - i), 2);
                            for (ulong k = 17; k >= Math.Max(n - i + 1, i + 1); k--)
                                res1 *= k;
                        }
                        else
                        {
                            res1 = ((decimal)fact(n, Math.Max(n - i + 1, i + 1)) / fact(Math.Min(i, n - i), 2));
                            //res1 = (fact(n, Math.Max(n - i + 1, i + 1)) / fact(Math.Min(i, n - i), 2));
                        }
                        //ulong res2=0;
                        decimal res2 = 0;
                        if ((Math.Max(m - j + 1, j + 1) < 18)&&(m>=28))
                        {
                            res2 = ((decimal)fact(m, 18) / (fact(Math.Min(j, m - j), 2)));
                            //res2 = (fact(m, 18) / (fact(Math.Min(j, m - j), 2)));
                            for (ulong k = 17; k >= Math.Max(m - j + 1, j + 1); k--)
                                res2 *= k;
                        }
                        else
                        {
                            res2 = ((decimal)fact(m, Math.Max(m - j + 1, j + 1)) / (fact(Math.Min(j, m - j), 2)));
                           // res2 = (fact(m, Math.Max(m - j + 1, j + 1)) / (fact(Math.Min(j, m - j), 2)));
                        }

                        //  Console.WriteLine(res1);
                        //   Console.WriteLine(res2);
                        sum += ((ulong)res1) * ((ulong)res2);
                    }
                }
            }
            Console.WriteLine(sum);
            Console.ReadLine();

        }
        static ulong fact(ulong n,ulong na4)
        {
            ulong res = 1;
            for (ulong i = na4; i <= n; i++)
                res *= i;
            return res;
        }
    }
}


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

namespace ConsoleApp
{
    class Program
    {
        const double DefaultEpsilon = 1e-18;

        struct Vector
        {
            public double X;
            public double Y;

            public Vector(double x, double y)
            {
                X = x;
                Y = y;
            }
            public Vector(double angle)
            {
                X = Math.Cos(angle);
                Y = Math.Sin(angle);
            }

            public double Hypot()
            {
                return Math.Sqrt((X * X) + (Y * Y));
            }
            public double HypotSquared()
            {
                return (X * X) + (Y * Y);
            }
            public Vector RotateClockwise(double angle)
            {
                double cos = Math.Cos(angle);
                double sin = Math.Sin(angle);

                return new Vector(X * cos + Y * sin, X * -sin + Y * cos);
            }
            public Vector Perpendicular()
            {
                return new Vector(-Y, X);
            }
            public bool IsEqual(Vector vector, double epsilon = DefaultEpsilon)
            {
                return Equal(this.X, vector.X, epsilon) && Equal(this.Y, vector.Y, epsilon);
            }

            public static Vector operator +(Vector a)
            {
                return a;
            }
            public static Vector operator -(Vector a)
            {
                return new Vector(-a.X, -a.Y);
            }
            public static Vector operator +(Vector a, Vector b)
            {
                return new Vector(a.X + b.X, a.Y + b.Y);
            }
            public static Vector operator -(Vector a, Vector b)
            {
                return new Vector(a.X - b.X, a.Y - b.Y);
            }
            public static double Determinant(Vector a, Vector b)
            {
                return (a.X * b.Y) - (a.Y * b.X);
            }
            public static double DotProduct(Vector a, Vector b)
            {
                return (a.X * b.X) + (a.Y * b.Y);
            }
        }
        struct Line
        {
            public double A;
            public double B;
            public double C;

            public double slopeY => -A / B; // y = f'(x)
            public double slopeX => -B / A; // x = f'(y)

            public Line(Vector p1, Vector p2)
            {
                A = p2.Y - p1.Y;
                B = p1.X - p2.X;
                C = p2.X * p1.Y - p1.X * p2.Y;
            }
        }
        struct Segment
        {
            public Vector Left;
            public Vector Right;

            public Segment(Vector left, Vector right)
            {
                Left = left;
                Right = right;
            }

            public Line GetLine()
            {
                return new Line(Left, Right);
            }
            public bool IsOnTheSegment(Vector point, double epsilon = DefaultEpsilon)
            {
                Vector v1 = point - Left;
                Vector v2 = point - Right;
                double det = Vector.Determinant(v1, v2);
                double dotProd = Vector.DotProduct(v1, v2);

                return Equal(det, 0, epsilon) && LessOrEqual(dotProd, 0, epsilon);
            }
        }

        static Program()
        {
            // Comment this before submitting (in case of strandard input)
            //Console.SetIn(new StreamReader("input.txt"));
            //Console.SetOut(new StreamWriter("output.txt"));
        }
        static void Main()
        {
            const int mod = 1_000_000_007;

            //int testcases = int.Parse(Console.ReadLine());
            //for (int z = 0; z < testcases; z++)
            //{

            //}

            int k = int.Parse(Console.ReadLine());
            long pow = PowQuick(2, k) - 2;
            long ans = PowQuick(4, pow, mod);

            ans *= 6;
            ans %= mod;

            Console.WriteLine(ans);

            Console.Out.Close();
        }
        static bool Equal(double a, double b, double epsilon = DefaultEpsilon)
        {
            return Math.Abs(a - b) < epsilon;
        }
        static bool Greater(double a, double b, double epsilon = DefaultEpsilon)
        {
            return (a > b) && !Equal(a, b, epsilon);
        }
        static bool Less(double a, double b, double epsilon = DefaultEpsilon)
        {
            return (a < b) && !Equal(a, b, epsilon);
        }
        static bool GreaterOrEqual(double a, double b, double epsilon = DefaultEpsilon)
        {
            return (a > b) || Equal(a, b, epsilon);
        }
        static bool LessOrEqual(double a, double b, double epsilon = DefaultEpsilon)
        {
            return (a < b) || Equal(a, b, epsilon);
        }
        static double DegToRad(double angle)
        {
            return (angle / 180) * Math.PI;
        }
        static long LCM(long a, long b)
        {
            return (a / GCD(a, b)) * b;
        }
        static long GCD(long a, long b)
        {
            while (a != 0)
            {
                b %= a;
                Swap(ref a, ref b);
            }

            return b;
        }
        static long PowQuick(long b, long p)
        {
            long exp = b;
            long res = 1;

            while (p > 0)
            {
                if ((p % 2) == 1)
                {
                    res *= exp;
                }

                exp *= exp;
                p /= 2;
            }

            return res;
        }
        static long PowQuick(long b, long p, long mod)
        {
            long exp = b;
            long res = 1;

            while (p > 0)
            {
                if ((p % 2) == 1)
                {
                    res *= exp;
                    res %= mod;
                }

                exp *= exp;
                exp %= mod;
                p /= 2;
            }

            return res;
        }
        static uint BitCount(uint a)
        {
            a = ((a >> 1) & 0x55555555u) + (a & 0x55555555u);
            a = ((a >> 2) & 0x33333333u) + (a & 0x33333333u);
            a = ((a >> 4) & 0x0F0F0F0Fu) + (a & 0x0F0F0F0Fu);
            a = ((a >> 8) & 0x00FF00FFu) + (a & 0x00FF00FFu);
            a = ((a >> 16) & 0x0000FFFFu) + (a & 0x0000FFFFu);
            return a;
        }
        static bool AreAlmostEqual(double a, double b, double epsilon)
        {
            return Math.Abs(a - b) < epsilon;
        }
        static int Binary(int[] array, int val)
        {
            return Binary(array, val, 0, array.Length);
        }
        static int Binary(int[] array, int val, int left, int right)
        {
            if (val < array[0])
            {
                return 0;
            }

            while (right - left > 1)
            {
                int mid = (right + left) / 2;

                if (array[mid] <= val)
                {
                    left = mid;
                }
                else
                {
                    right = mid;
                }
            }

            return right;
        }
        static void Swap(ref int a, ref int b)
        {
            int temp = a;
            a = b;
            b = temp;
        }
        static void Swap(ref long a, ref long b)
        {
            long temp = a;
            a = b;
            b = temp;
        }
        static double[] ReadDoubleData(TextReader input)
        {
            return input.ReadLine()
                .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(val => double.Parse(val))
                .ToArray();
        }
        static double[] ReadDoubleData()
        {
            return ReadDoubleData(Console.In);
        }
        static int[] ReadIntData(TextReader input)
        {
            return input.ReadLine()
                .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(val => int.Parse(val))
                .ToArray();
        }
        static int[] ReadIntData()
        {
            return ReadIntData(Console.In);
        }
        static long[] ReadLongData(TextReader input)
        {
            return input.ReadLine()
                .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(val => long.Parse(val))
                .ToArray();
        }
        static long[] ReadLongData()
        {
            return ReadLongData(Console.In);
        }
    }
}


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

public class HelloWorld {
    static public void Main () {
        SolveCodeForces();
        // Test();
        // System.Console.WriteLine(Brute(995));
    }

    public static void SolveCodeForces() {
        var n = ulong.Parse(Console.ReadLine());
        var ans = SolveCF(n);
        System.Console.WriteLine(ans);
    }

    public static ulong SolveCF(ulong n) {
        var s = n.ToString();

        var ans = 0ul;
        var carry = false;

        for (var i = s.Length - 1; i >= 0; i--) {

            var d = int.Parse(s[i].ToString());
            int curr;
            bool newcarry;

            if (i == s.Length - 1 && s.Length > 1) {
                newcarry = d <= 8;
                curr = newcarry ? (d + 10) : d;
            }

            else if (i > 0) {
                newcarry = carry ? true : (d <= 8);
                curr = (newcarry ? (d + 10) : d) - (carry ? 1 : 0);
            }

            else {
                newcarry = false;
                curr = d - (carry ? 1 : 0);
            }

            ans += (ulong)curr;
            carry = newcarry;

            // System.Console.WriteLine(new { s, i, curr, carry, ans });
        }

        return ans;
    }

    public static ulong S(ulong v) {
        return (ulong)v.ToString().Select(c => int.Parse(c.ToString())).Sum();
    }

    public static ulong Brute(ulong n) {
        var ans = 0ul;
        for (var a = 0ul; a <= n; a++) {
            var b = (ulong)(n - a);
            // if (S(a) + S(b) > ans)
            //     System.Console.WriteLine(new { a, b });
            ans = Math.Max( ans, S(a) + S(b) );
        }
        return ans;
    }

    public static void Test() {
        var rnd = new Random(12);
        for (var t = 0; t < 1000; t++) {
            var n = (ulong)rnd.Next(0, 1000);

            var brute = Brute(n);
            var actual = SolveCF(n);

            if (brute != actual) {
                System.Console.WriteLine(new { t, n, brute, actual });
                return;
            }
        }
        System.Console.WriteLine("Ok");
    }
}


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

namespace TShirtHunt
{
    class Program
    {
        static List<int> TShirtWinners(int x)
        {
            List<int> winners = new List<int>();
            int i = (x / 50) % 475;
            for (int j = 1; j <= 25; j++)
            {
                i = (i * 96 + 42) % 475;
                winners.Add(26 + i);
            }
            return winners;
        }

        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split();
            int p = int.Parse(line[0]);
            int x = int.Parse(line[1]);
            int y = int.Parse(line[2]);

            int newX = x;
            while (newX >= y && !TShirtWinners(newX).Contains(p))
            {
                newX -= 50;
            }
            if (newX >= y)
            {
                Console.WriteLine("0");
                return;
            }

            int numberOfIncreasingBy50 = Math.Max(1, (int)Math.Ceiling((double)(y - x) / 50));
            while (!TShirtWinners(x + numberOfIncreasingBy50 * 50).Contains(p))
                numberOfIncreasingBy50++;
            Console.WriteLine((numberOfIncreasingBy50 + 1) / 2);
        }
    }
}


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

namespace CodeForces
{
	internal class B
	{
		private int MOD = 1000000007;
		private int n;
		private long m;
		private int k;
		private int[,] dp;
		private bool[,] was;
		private int[,] bin, pw;

		int go( int pos, int k )
		{
			if ( pos == n )
			{
				if ( k == 0 ) return 1;
				return 0;
			}
			if ( was[pos, k] )
				return dp[pos, k];
			int res = go( pos + 1, k );

			for ( int i = 1; i <= n && i <= k; ++i )
			{
				int tmp = (int)( ( (long)pw[pos, i] * go( pos + 1, k - i ) ) % MOD );
				res += tmp;
				if ( res >= MOD ) res -= MOD;
			}

			was[pos, k] = true;
			return dp[pos, k] = res;
		}

		private int pow( int a, long b )
		{
			if ( b == 0 ) return 1;
			int tmp = pow( a, b / 2 );
			tmp = (int)( ( (long)tmp * tmp ) % MOD );
			if ( b % 2 == 1 )
			{
				tmp = (int)( ( (long)tmp * a ) % MOD );
			}
			return tmp;
		}

		private void Solve()
		{
			n = NextInt();
			m = NextLong();
			k = NextInt();

			bin = new int[101, 101];
			for ( int i = 0; i <= 100; ++i )
			{
				bin[i, 0] = bin[i, i] = 1;
				for ( int j = 1; j < i; ++j ) bin[i, j] = ( bin[i - 1, j] + bin[i - 1, j - 1] ) % MOD;
			}
			pw = new int[101, 101];
			for ( int pos = 0; pos < n; ++pos )
			{
				long cnt = ( ( ( m - pos ) % n ) == 0 ? ( m - pos ) / n - 1 : ( m - pos ) / n ) + 1;
				for ( int i = 1; i <= n; ++i )
				{
					pw[pos, i] = pow( bin[n, i], cnt );
				}
			}

			dp = new int[n, n * n + 1];
			was = new bool[n, n * n + 1];
			Out.WriteLine( go( 0, k ) );
		}

		#region Local wireup

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

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

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

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

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

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

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

		class Scanner : IDisposable
		{
			#region Fields

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

			#endregion

			#region .ctors

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

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

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

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

			#endregion

			#region IDisposable Members

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

			#endregion

			#region Properties

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

			#endregion

			#region Methods

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

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

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

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

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

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

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

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

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

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

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

			#endregion
		}

		#endregion
	}
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using static System.Math;

namespace Olymp
{
  public class ProblemSolver
  {
    private Tokenizer input;

    public void Solve()
    {
      int n = input.ReadInt();
      var c = new HashSet<int>();
      for (int a = 0; a <= 33; a++)
      {
        for (int b = 0; 7 * b <= 100 - 3 * a; b++)
        {
          c.Add(3 * a + 7 * b);
        }
      }
      for (int i = 0; i < n; i++)
      {
        int x = input.ReadInt();
        Console.WriteLine(c.Contains(x) ? "YES" : "NO");
      }
    }

    public ProblemSolver(TextReader input)
    {
      this.input = new Tokenizer(input);
    }

    #region Service functions

    private static int GCD(int a, int b)
    {
      while (b != 0)
      {
        a %= b;
        int t = b;
        b = a;
        a = t;
      }
      return a;
    }

    #endregion
  }

  #region Service classes

  public class Tokenizer
  {
    private TextReader reader;

    public int ReadInt()
    {
      var c = SkipWS();
      if (c == -1)
        throw new EndOfStreamException();
      bool isNegative = false;
      if (c == '-' || c == '+')
      {
        isNegative = c == '-';
        c = this.reader.Read();
        if (c == -1)
          throw new InvalidOperationException();
      }
      if (!char.IsDigit((char)c))
        throw new InvalidOperationException();
      int result = (char)c - '0';
      c = this.reader.Read();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        if (!char.IsDigit((char)c))
          throw new InvalidOperationException();
        result = result * 10 + (char)c - '0';
        c = this.reader.Read();
      }
      if (isNegative)
        result = -result;
      return result;
    }

    public string ReadLine()
    {
      return reader.ReadLine();
    }

    public long ReadLong()
    {
      return long.Parse(this.ReadToken());
    }

    public double ReadDouble()
    {
      return double.Parse(this.ReadToken(), CultureInfo.InvariantCulture);
    }

    public int[] ReadIntArray(int n)
    {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = ReadInt();
      return a;
    }

    public long[] ReadLongArray(int n)
    {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = ReadLong();
      return a;
    }

    public double[] ReadDoubleArray(int n)
    {
      double[] a = new double[n];
      for (int i = 0; i < n; i++)
        a[i] = ReadDouble();
      return a;
    }

    public string ReadToken()
    {
      var c = SkipWS();
      if (c == -1)
        return null;
      var sb = new StringBuilder();
      while (c > 0 && !char.IsWhiteSpace((char)c))
      {
        sb.Append((char)c);
        c = this.reader.Read();
      }
      return sb.ToString();
    }

    private int SkipWS()
    {
      int c = this.reader.Read();
      if (c == -1)
        return c;
      while (c > 0 && char.IsWhiteSpace((char)c))
        c = this.reader.Read();
      return c;
    }

    public Tokenizer(TextReader reader)
    {
      this.reader = reader;
    }
  }

  class Program
  {
    public static void Main(string[] args)
    {
      var solver = new ProblemSolver(Console.In);
      solver.Solve();
    }
  }

  #endregion
}


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

namespace CodeForces
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int[] nums = Console.ReadLine ().Split (' ').Select (int.Parse).ToArray ();
			Dictionary<int,int> cards = new Dictionary <int,int> ();
			foreach (int i in nums) {
				if (!cards.ContainsKey (i))
					cards.Add (i, 0);
				cards [i]++;
			}
			int best = nums.Sum ();
			foreach (KeyValuePair<int,int> pair in cards) {
				if (pair.Value > 1) {
					int count = pair.Value;
					if (count > 3)
						count = 3;
					int tmp = nums.Sum () - pair.Key * count;
					if (tmp < best)
						best = tmp;
				}
			}
			Console.WriteLine (best);
		}
	}
}


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

class P {
  static IEnumerable<long> GetNums() {
    for (var i = 0L ;  ; i++) {
      var c = i;
      var res = 0L; var mult = 1L;
      var d4 = 0; var d7 = 0;
      while (c > 0) {
        int dig;
        if (c > 2) {
          var o = (c - 1)%2 + 1;
          c -= o;
          dig = o == 1 ? 4 : 7;
        } else {
          c--;
          dig = (c == 0 ? 4 : 7);
        }
        if (dig == 4) d4++; else d7++;
        res += mult * dig;
        c /= 2;
        mult *= 10;
      }
      if (d4 == d7)
        yield return res;
    }
  }

  public static void Main() {
    long n = long.Parse(Console.ReadLine());
    var res = GetNums().First(x => x >= n);
    Console.Write(res);
  }
}


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

namespace CodeForces
{
    class R200_Div2_C
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            long a = long.Parse(s[0]);
            long b = long.Parse(s[1]);

            long cnt = a/b, x;
            a %= b;
            while (a > 0)
            {
                x = a; a = b; b = x;
                cnt += (a / b);
                a %= b;
            }
            Console.WriteLine(cnt);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;

/*
   Aryanium Shadowhunter
*/

namespace CodeForces
{
    class Program
    {

        public static void Main(string[] args)
        {
            GregorianCalendar gCalendar = new GregorianCalendar();
            DateTime dTime = new DateTime(2016,1,1,gCalendar);
            string input = Console.ReadLine();
            int count = 0;
            if (input.Contains("week"))
            {
                int day = int.Parse(input.Replace(" of week", " "));
                DayOfWeek dayWeek = new DayOfWeek();

                switch (day)
                {
                    case 1:dayWeek = DayOfWeek.Monday;break;
                    case 2: dayWeek = DayOfWeek.Tuesday; break;
                    case 3: dayWeek = DayOfWeek.Wednesday; break;
                    case 4: dayWeek = DayOfWeek.Thursday; break;
                    case 5: dayWeek = DayOfWeek.Friday; break;
                    case 6: dayWeek = DayOfWeek.Saturday; break;
                    case 7: dayWeek = DayOfWeek.Sunday; break;

                }

                for (int i = 0; i < gCalendar.GetDaysInYear(2016); i++)
                {
                    if (gCalendar.GetDayOfWeek(dTime) == dayWeek) count++;
                    dTime = gCalendar.AddDays(dTime, 1);
                }
            }
            else
            {
                int day = int.Parse(input.Replace(" of month", " "));
                for (int i = 1; i < 13; i++)
                {
                    if (day <= gCalendar.GetDaysInMonth(2016, i)) count++ ;
                }
            }

            Console.WriteLine(count);

        }

    }
}


using System;

namespace ConsoleApplication1
{

    class Program
    {
        static void Main(string[] args)
        {
            string[] t = Console.ReadLine().Split(' ');
            int l = int.Parse(t[0]);
            int d = int.Parse(t[1]);
            int v = int.Parse(t[2]);
            int g = int.Parse(t[3]);
            int r = int.Parse(t[4]);
            double ans = 0;
            double t1 = (double)d / (double)v;
            double w = (double)l / (double)v;
            t1 %= g + r;
            if (t1 < g)
                ans = w;
            if (t1 == g)
                ans = w + r;
            if (t1 > g)
                ans = w + r - (t1 - g);
            string s = String.Format("{0:0.######}", ans).Replace(',','.');
            Console.WriteLine(s);
        }
    }
}


using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        string[] str = Console.ReadLine().Split(' ');
        long X = long.Parse(str[0]);
        long Y = long.Parse(str[1]);
        Generateprimenumber G = new Generateprimenumber(1000003);
        long[] Div = G.Divisor(X);
        long count = 0;
        while(Y != 0){
            long Z = gcd(X,Y);
            X /= Z;
            Y /= Z;
            long min = Y;
            for(int i=0;i<Div.Length;i++){
                if(X % Div[i] == 0){
                    min = Math.Min(min,Y % Div[i]);
                }
            }
            count += min;
            Y -= min;
        }
        sb.Append(count+"\n");
    }
    long gcd(long x,long y){
        if(y == 0){
            return x;
        }
        else{
            return gcd(y,x%y);
        }
    }
}
class Generateprimenumber{
    public long[] p;
    public int length;
    public Generateprimenumber(int n){
        bool[] a = new bool[n+1];
        List<long> pp = new List<long>();
        int j = 2;
        for(int i=0;i<n+1;i++){
            a[i] = true;
        }
        while(j<=n){
            if(a[j]){
                pp.Add(j);
                for(int i=j;(long)i*(long)j<=n;i++){
                    a[i*j] = false;
                }
            }
            j++;
        }
        length = pp.Count;
        p = pp.ToArray();
    }
    public long[] Divisor(long n){
        List<long> pp = new List<long>();
        long num = n;
        for(int i=0;p[i]*p[i] <= num;i++){
            if(num % p[i] == 0){
                pp.Add(p[i]);
            }
            while(num % p[i] == 0){
                num /= p[i];
            }
        }
        if(num != 1){
            pp.Add(num);
        }
        return pp.ToArray();
    }
}


using System;

namespace Xorygol
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            int n = Convert.ToInt32(Console.ReadLine());
            for (int a = 1; a <= n; a++)
            {
                for (int b = a; b <= n; b++)
                {
                    int c = a ^ b;
                    if((b + a > c) && (a + c > b) && (c + b > a) && (c >= b) && (c <= n))
                    {
                        count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


using System;

namespace CSharp
{
    public class _651A
    {
        public static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split();

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

            int minutes = 0;

            while (Math.Min(a1, a2) > 0 && Math.Max(a1, a2) > 1)
            {
                int min = Math.Min(a1, a2);
                int max = Math.Max(a1, a2);

                a1 = min + 1;
                a2 = max - 2;

                minutes++;
            }

            Console.WriteLine(minutes);
        }
    }
}


using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var cnt = Console.ReadLine();
            var split = cnt.Split(' ');
            int n = int.Parse(split[0]);
            int m = int.Parse(split[1]);
            for(int i=0;i<n;i++)
            {
                var t = Console.ReadLine();
                if (t.Contains("C") || t.Contains("M") || t.Contains("Y"))
                {
                    Console.WriteLine("#Color");
                    return;
                }
            }
            Console.WriteLine("#Black&White");
        }
    }
}


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

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

        private static void Main(string[] args)
        {
            int k = Next(), b = Next(), n = Next(), t = Next();

            long sum = 1;
            int p = 0;
            while (sum * k + b <= t)
            {
                sum = sum*k + b;
                p++;
            }

            writer.WriteLine(Math.Max(0, n - p));
            writer.Flush();
        }

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


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

namespace Contest_14
{
    class Program
    {
        static void A()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int m = int.Parse(t[1]);

            int x1 = int.MaxValue, x2 = int.MinValue, y1 = int.MaxValue, y2 = int.MinValue;
            List<string> a = new List<string>();
            for (int i = 0; i < n; i++)
            {
                string s = Console.ReadLine();
                a.Add(s);
                for (int j = 0; j < m; j++)
                {
                    if (s[j] == '*')
                    {
                        if (x1 > i)
                            x1 = i;
                        if (x2 < i)
                            x2 = i;
                        if (y1 > j)
                            y1 = j;
                        if (y2 < j)
                            y2 = j;
                    }
                }
            }

            for (int i = x1; i <= x2; i++)
            {
                for (int j = y1; j <= y2; j++)
                {
                    Console.Write(a[i][j]);
                }
                Console.WriteLine();
            }
        }

        static void B()
        {
            var t = Console.ReadLine().Split(' ');
            int n = int.Parse(t[0]);
            int x = int.Parse(t[1]);

            int min = int.MaxValue;
            int max = int.MinValue;
            int[] a = new int[1001];
            for (int i = 0; i < n; i++)
            {
                t = Console.ReadLine().Split(' ');
                int k = int.Parse(t[0]);
                int l = int.Parse(t[1]);

                if (k > l)
                {
                    int q = k;
                    k = l;
                    l = q;
                }
                if (i == 0)
                {
                    min = k;
                    max = l;
                    continue;
                }
                if (k > min)
                {
                    min = k;
                }
                if (l < max)
                    max = l;
            }
            if (max < min)
            {
                Console.WriteLine(-1);
                return;
            }
            if ((x >= min) && (x <= max))
                Console.WriteLine(0);
            else
                Console.WriteLine(Math.Min(Math.Abs(min - x), Math.Abs(max - x)));
        }

        class Point : IComparer<Point>
        {
            public int x;
            public int y;

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

            public int Compare(Point p1, Point p2)
            {
                if (p1.x != p2.x)
                    return p1.x.CompareTo(p2.x);
                else
                    return p1.y.CompareTo(p2.y);
            }

            public bool isGood (Point p)
            {
                if ((x == p.x) && (y != p.y))
                    return true;
                if ((y == p.y) && (x != p.x))
                    return true;
                return false;
            }

            public void deleteInList(List<Point> b)
            {
                for (int j = 0; j < b.Count; j++)
                {
                    Point temp = b[j];
                    if ((temp.x == this.x) && (temp.y == this.y))
                    {
                        b.RemoveAt(j);
                        break;
                    }
                }

            }

        }

        static void C()
        {
            List<int[]> a = new List<int[]>();

            for (int i = 0; i < 4; i++)
            {
                var t = Console.ReadLine().Split(' ');
                var t1 = new int[] { int.Parse(t[0]), int.Parse(t[1]), int.Parse(t[2]), int.Parse(t[3]) };
                for (int j = 0; j < a.Count; j++)
                {
                    var k = a[j];

                    if ((k[0] == t1[0]) && (k[1] == t1[1]) && (k[2] == t1[2]) && (k[3] == t1[3]))
                    {
                        Console.WriteLine("NO");
                        return;
                    }

                    if ((k[2] == t1[0]) && (k[3] == t1[1]) && (k[0] == t1[2]) && (k[1] == t1[3]))
                    {
                        Console.WriteLine("NO");
                        return;
                    }
                }
                a.Add(t1);

            }

            List<Point> b = new List<Point>();

            int xl = int.MaxValue, yl = int.MinValue, xr = int.MinValue, yr = int.MaxValue;

            for (int i = 0; i < 4; i++)
            {
                int[] t = a[i];
                Point l1 = new Point(t[0], t[1]);
                Point l2 = new Point(t[2], t[3]);
                b.Add(l1);
                b.Add(l2);
                if (t[0] < xl)
                    xl = t[0];
                if (t[1] > yl)
                    yl = t[1];
                if (t[2] > xr)
                    xr = t[2];
                if (t[3] < yr)
                    yr = t[3];
                if (!l1.isGood(l2))
                {
                    Console.WriteLine("NO");
                    return;
                }
            }

            Point p1 = new Point(xl, yl);
            Point p2 = new Point(xr, yr);

            for (int i = 0; i < 2; i++)
            {
                p1.deleteInList(b);
                p2.deleteInList(b);
                new Point(p1.x, p2.y).deleteInList(b);
                new Point(p2.x, p1.y).deleteInList(b);
            }
            if (b.Count > 0)
                Console.WriteLine("NO");
            else Console.WriteLine("YES");
        }

        static void Main(string[] args)
        {
            //Console.SetIn(new StreamReader(@"C:\1.txt"));
            C();
        }
    }
}


using System;

namespace codeforces99B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            for(int i=2;i<=n;i++)
            {
                if(n%i==0)
                {
                    s= Reverse(s.Substring(0, i)) + s.Substring(i);
                }
            }
            Console.WriteLine(s);
        }
        private static string Reverse(string str)
        {
            string res = "";
            for (int i = 0; i < str.Length; i++)
                res = str[i] + res;
           // Console.WriteLine(res);
            return res;
        }
    }
}


// Problem: 965A - Paper Airplanes
// Author: Gusztav Szmolik

using System;

class PaperAirplanes
    {
    static int Main ()
        {
        string line = Console.ReadLine ();
        if (line == null)
            return -1;
        char[] delims = {' ', '\t'};
        string[] words = line.Split (delims,StringSplitOptions.RemoveEmptyEntries);
        if (words.Length != 4)
            return -1;
        ushort k;
        if (!UInt16.TryParse (words[0], out k))
            return -1;
        if (k < 1 || k > 10000)
            return -1;
        ushort n;
        if (!UInt16.TryParse (words[1], out n))
            return -1;
        if (n < 1 || n > 10000)
            return -1;
        ushort s;
        if (!UInt16.TryParse (words[2], out s))
            return -1;
        if (s < 1 || s > 10000)
            return -1;
        ushort p;
        if (!UInt16.TryParse (words[3], out p))
            return -1;
        if (p < 1 || p > 10000)
            return -1;
        ushort numSheetEachPeople = Convert.ToUInt16 (n%s == 0 ? n/s : n/s+1);
        uint totalNumSheet = Convert.ToUInt32 (k*numSheetEachPeople);
        uint ans = (totalNumSheet%p == 0 ? totalNumSheet/p : totalNumSheet/p+1);
        Console.WriteLine (ans);
        return 0;
        }
    }


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace learnSharp
{
    public delegate void PayDelegate();
    public delegate void AddDelegate();
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] leeterOfS = s.ToCharArray();
            int n = 0;

            char[] odd = { '1', '3', '5', '7' ,'9' };
            char[] vowel = { 'a', 'i', 'o', 'u', 'e' };

            for(int i = 0; i < s.Length; i++)
            {
                for(int v = 0; v < vowel.Length; v++)
                {
                    if (leeterOfS[i] == vowel[v])
                    {
                        n += 1;
                    }
                }
            }

            for(int i = 0; i < s.Length; i++)
            {
                for(int e = 0; e < odd.Length; e++)
                {
                    if (leeterOfS[i] == odd[e])
                    {
                        n += 1;
                    }
                }
            }

            Console.WriteLine(n);
        }
    }
}


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

namespace Blocked_Points
{
    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)
        {
            long n = Next();

            long count;
            if (n == 1)
                count = 4;

            else if (n == 2)
                count = 8;
            else if (n == 0)
                count = 1;
            else
            {

                long y = (long)Math.Sqrt(n/2*n)+2;
                long nn = n*n;

                while (2*y*y > nn)
                {
                    y--;
                }
                if (y*y + (y+1)*(y+1) > nn)
                {
                    count = (y)*8;
                }
                else
                {
                    count = (2*y + 1)*4;
                }
            }

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

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


using System;
using System.Linq;

namespace CSharp
{
    public class _849A
    {
        public static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(token => int.Parse(token)).ToArray();

            Console.WriteLine((a.Length * a.First() * a.Last()) % 2 == 1 ? "Yes" : "No");
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;
using Debug = System.Diagnostics.Debug;
using SB = System.Text.StringBuilder;
using System.Numerics;
using static System.Math;
namespace Program {
    public class Solver {
        Random rnd = new Random(0);
        public void Solve() {
            var n = rl;
            var k = ri;
            solve(n, k);
        }
        void solve(long n, int k) {
            Debug.WriteLine($"{n} {k}");
            var rev = Enumerate(100, x => ModInt.Inverse(x));

            ModInt all = 1;
            for (long p = 2; n != 1; p++) {
                if (p * p > n) {
                    p = n;
                }
                if (n % p != 0) continue;
                var cnt = 0;
                while (n % p == 0) {
                    n /= p;
                    cnt++;
                }
                var dp = new ModInt[cnt + 1];
                dp[cnt] = 1;
                for (int i = 0; i < k; i++) {
                    var next = new ModInt[cnt + 1];
                    for (int j = 0; j < dp.Length; j++)
                        for (int jj = 0; jj <= j; jj++) {
                            next[jj] += dp[j] * rev[j + 1];
                        }
                    dp = next;
                }
                ModInt ans = 0;
                for (long i = 0, v = 1; i < dp.Length; i++, v *= p)
                    ans += v * dp[i];
                all *= ans;

            }
            Console.WriteLine(all);
        }
        const long INF = 1L << 60;
        int ri { get { return sc.Integer(); } }
        long rl { get { return sc.Long(); } }
        double rd { get { return sc.Double(); } }
        string rs { get { return sc.Scan(); } }
        public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

        static T[] Enumerate<T>(int n, Func<int, T> f) {
            var a = new T[n];
            for (int i = 0; i < n; ++i) a[i] = f(i);
            return a;
        }
        static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
    }
}

#region main
static class Ex {
    static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
    static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
        return string.Join(st, ie);
    }
    static public void Main() {
        Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Program.Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}
#endregion
#region Ex
namespace Program.IO {
    using System.IO;
    using System.Text;
    using System.Globalization;

    public class Printer: StreamWriter {
        public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
        public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
    }

    public class StreamScanner {
        public StreamScanner(Stream stream) { str = stream; }

        public readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }

        private byte read() {
            if (isEof) return 0;
            if (ptr >= len) {
                ptr = 0;
                if ((len = str.Read(buf, 0, 1024)) <= 0) {
                    isEof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }

        public char Char() {
            byte b = 0;
            do b = read(); while ((b < 33 || 126 < b) && !isEof);
            return (char)b;
        }
        public string Scan() {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
            return sb.ToString();
        }
        public string ScanLine() {
            var sb = new StringBuilder();
            for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
            return sb.ToString();
        }
        public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
        public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
        public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
}

#endregion

#region sieve O(NloglogN)
static public partial class MathEx {
    static public bool[] Sieve(int p, List<int> primes = null) {
        var isPrime = new bool[p + 1];
        for (int i = 2; i < isPrime.Length; i++) isPrime[i] = true;
        for (int i = 2; i * i <= p; i++)
            if (!isPrime[i]) continue;
            else for (int j = i * i; j <= p; j += i) isPrime[j] = false;
        if (primes != null) for (int i = 0; i <= p; i++) if (isPrime[i]) primes.Add(i);

        return isPrime;
    }
    static public List<int> SieveList(int p) { var ret = new List<int>(); Sieve(p, ret); return ret; }
}
#endregion

#region ModInt
/// <summary>
/// [0,<see cref="Mod"/>) までの値を取るような数
/// </summary>
public struct ModInt {
    /// <summary>
    /// 剰余を取る値．
    /// </summary>
    public const long Mod = (int)1e9 + 7;

    /// <summary>
    /// 実際の数値．
    /// </summary>
    public long num;
    /// <summary>
    /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
    /// </summary>
    /// <param name="n">インスタンスが持つ値</param>
    /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
    public ModInt(long n) { num = n; }
    /// <summary>
    /// このインスタンスの数値を文字列に変換します．
    /// </summary>
    /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
    public override string ToString() { return num.ToString(); }
    public static ModInt operator +(ModInt l, ModInt r) { l.num += r.num; if (l.num >= Mod) l.num -= Mod; return l; }
    public static ModInt operator -(ModInt l, ModInt r) { l.num -= r.num; if (l.num < 0) l.num += Mod; return l; }
    public static ModInt operator *(ModInt l, ModInt r) { return new ModInt(l.num * r.num % Mod); }
    public static implicit operator ModInt(long n) { n %= Mod; if (n < 0) n += Mod; return new ModInt(n); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(ModInt v, long k) { return Pow(v.num, k); }

    /// <summary>
    /// 与えられた 2 つの数値からべき剰余を計算します．
    /// </summary>
    /// <param name="v">べき乗の底</param>
    /// <param name="k">べき指数</param>
    /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
    public static ModInt Pow(long v, long k) {
        long ret = 1;
        for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
            if ((k & 1) == 1) ret = ret * v % Mod;
        return new ModInt(ret);
    }
    /// <summary>
    /// 与えられた数の逆元を計算します．
    /// </summary>
    /// <param name="v">逆元を取る対象となる数</param>
    /// <returns>逆元となるような値</returns>
    /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
    public static ModInt Inverse(ModInt v) { return Pow(v, Mod - 2); }
}
#endregion


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

class Program
{
    public class SegmentTreeAssignSum
    {
        int n;
        int h;
        int[] t;
        int[] d;

        public SegmentTreeAssignSum(int capacity)
        {
            this.n = capacity;
            this.t = new int[capacity + capacity];
            this.d = new int[capacity + capacity];
            this.h = 1;
            while (this.h < capacity) this.h *= 2;
            if (h > capacity) h /= 2;
        }

        private void Calc(int p, int k)
        {
            if (d[p] == 0)
                t[p] = t[p << 1] + t[p << 1 | 1];
            else
                t[p] = d[p] * k;
        }

        private void Apply(int p, int value, int k)
        {
            t[p] = value * k;
            if (p < n)
            {
                d[p] = value;
            }
        }

        private void Build(int l, int r)
        {
            int k = 2;
            for (l += n, r += n - 1; l > 1; k <<= 1)
            {
                l >>= 1;
                r >>= 1;
                for (int i = r; i >= l; --i)
                    this.Calc(i, k);
            }
        }

        private void Push(int l, int r)
        {
            int s = h, k = 1 << (h - 1);
            for (l += n, r += n - 1; s > 0; --s, k >>= 1)
                for (int i = l >> s; i <= r >> s; ++i)
                    if (d[i] != 0)
                    {
                        this.Apply(i << 1, d[i], k);
                        this.Apply(i << 1 | 1, d[i], k);
                        d[i] = 0;
                    }
        }

        public void Modify(int l, int r, int value)
        {
            r++;
            if (value == 0) return;
            this.Push(l, l + 1);
            this.Push(r - 1, r);
            int l0 = l, r0 = r, k = 1;
            for (l += n, r += n; l < r; l >>= 1, r >>= 1, k <<= 1)
            {
                if (l % 2 == 1) this.Apply(l++, value, k);
                if (r % 2 == 1) this.Apply(--r, value, k);
            }
            this.Build(l0, l0 + 1);
            this.Build(r0 - 1, r0);
        }

        public int GetSum(int l, int r)
        {
            r++;
            this.Push(l, l + 1);
            this.Push(r - 1, r);
            int result = 0;
            for (l += n, r += n; l < r; l >>= 1, r >>= 1)
            {
                if (l % 2 == 1) result += t[l++];
                if (r % 2 == 1) result += t[--r];
            }
            return result;
        }
    }

    public class SegmentTree2
    {
        private int Mid = 1024 * 128;
        private int[] t;
        private int[] d;

        public SegmentTree2(int[] a)
        {
            this.Mid = 1;
            while (Mid < a.Length) Mid *= 2;
            this.t = new int[Mid + Mid];
            this.d = new int[Mid + Mid];

            for (int i = 0; i < a.Length; i++) t[Mid + i] = a[i];
            for (int i = Mid - 1; i > 0; i--)
                t[i] = t[i + i] + t[i + i + 1];
        }

        private void push(int v)
        {
            if (t[v] != -1)
            {
                t[v * 2] = t[v * 2 + 1] = t[v];
                t[v] = -1;
            }
        }

        public void update(int v, int tl, int tr, int l, int r, int color)
        {
            if (l > r)
                return;
            if (l == tl && tr == r)
                t[v] = color;
            else
            {
                push(v);
                int tm = (tl + tr) / 2;
                update(v * 2, tl, tm, l, Math.Min(r, tm), color);
                update(v * 2 + 1, tm + 1, tr, Math.Max(l, tm + 1), r, color);
            }
        }

        public int get(int v, int tl, int tr, int pos)
        {
            if (tl == tr)
                return t[v];
            push(v);
            int tm = (tl + tr) / 2;
            if (pos <= tm)
                return get(v * 2, tl, tm, pos);
            else
                return get(v * 2 + 1, tm + 1, tr, pos);
        }

    }

    public class AssignmentBf
    {
        private int[] t;
        public AssignmentBf(int capacity)
        {
            this.t = new int[capacity];
        }

        public void Modifu(int l, int r, int v)
        {
            for (int i = l; i <= r; i++) t[i] = v;
        }

        public int GetSum(int l, int r)
        {
            int sum = 0;
            for (int i = l; i <= r; i++) sum += t[i];
            return sum;
        }

        public int GetMax(int l, int r)
        {
            int max = t[l];
            for (int i = l; i <= r; i++)
                max = Math.Max(max, t[i]);
            return max;
        }
    }

    private static StringBuilder sb = new StringBuilder();
    private static bool Can(long x, long y, bool reverse = false)
    {
        if (x > y) return Can(y, x, true);
        if (x == 0) sb.Append(y + (reverse ? "A" : "B"));
        if (x == 0) return true;
        if (x == y) return false;
        sb.Append((y / (x + 1)) + (reverse ? "A" : "B"));
        return Can(y % (x + 1), x, !reverse);
    }

    static void Main(string[] args)
    {
        long x = ReadLong();
        long y = ReadLong();
        if (!Can(x - 1, y - 1))
            Console.WriteLine("Impossible");
        else
            Console.Write(sb.ToString());

        /*
        int[] b = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

        var st3 = new SegmentTree2(b);

        var q1 = st3.get(6, 9);
        st3.get(9, 9, 8);
        var q2 = st3.get(6, 9);
        st3.get(9, 9, 1);
        var q3 = st3.get(6, 9);

        st3.Update(3, 7, 9);

        st3.Print();

        int id = 0;
        int maxValue = 10;
        int size = 10;

        while (true)
        {
            id++;

            var x = new Random();
            int[] a = new int[size];
            for (int i = 0; i < a.Length; i++) a[i] = x.Next(maxValue);

            //int[] a = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            var st2 = new SegmentTree2(a);
            var bf = new AssignmentBf(a.Length);
            for (int i = 0; i < a.Length; i++) bf.Modifu(i, i, a[i]);

            for (int i = 0; i < 100000; i++)
            {
                int l = x.Next(a.Length);
                int r = x.Next(l, a.Length);
                if (x.Next(5) == 1)
                {
                    int v = x.Next(maxValue);
                    st2.Update(l, r, v);
                    bf.Modifu(l, r, v);
                }
                else
                {
                    var s1 = st2.GetSum(l, r);
                    var s2 = bf.GetSum(l, r);
                    if (s1 != s2)
                    {
                        Console.WriteLine("WRONG");
                    }
                }
            }

        */
        //Console.WriteLine("COMPLETED " + id++);
        //}

        /*
                Verify("abcde", "a", false);
                Verify("abcde", "a%", true);
                Verify("abcde", "%a", false);
                Verify("abcde", "b", false);
                Verify("abcde", "b%", false);
                Verify("abcde", "%b", false);

                Verify("25%", "_5[%]", true);
                Verify("_52", "_5[%]5%", true);

                Verify("ab", "a[a-cdf]]", true);
                Verify("ad", "a[a-cdf]", true);
                Verify("ab", "a[-acdf]", false);
                Verify("a-", "a[-acdf]", true);

                Verify("[]", "'[[]]", true);
                Verify("''", "_'", true);
                Verify("U", "[^a-zA-Z0-9]", false);
                */
        /*
      int n = ReadInt();
      int[] m = ReadIntArray(n);

      double x = -10000;
      double vx = Value(m, x);
      double prevVx = vx;
      double step = 1000;
      int iteration = 0;
      while (iteration < 228)
      {
          iteration++;
          double next = Value(m, x + step);
          if (next <= vx)
          {
              prevVx = vx;
              vx = next;
              x += step;
          }
          else
          {
              x -= step;
              vx = prevVx;
              step = step / 2;
          }
      }

      Console.WriteLine(vx.ToString().Replace(',', '.'));*/
    }

    private static List<int>[] ReadGraph()
    {
        int n = ReadInt();
        int m = ReadInt();
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < n; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = ReadInt() - 1;
            int b = ReadInt() - 1;
            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[] ReadIntArray()
    {
        string[] tmp = Console.ReadLine().Split(' ');
        int[] ans = new int[tmp.Length];
        for (int i = 0; i < tmp.Length; i++) ans[i] = int.Parse(tmp[i]);
        return ans;
    }

    private static long[] ReadLongArray()
    {
        string[] tmp = Console.ReadLine().Split(' ');
        long[] ans = new long[tmp.Length];
        for (int i = 0; i < tmp.Length; i++) ans[i] = long.Parse(tmp[i]);
        return ans;
    }

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

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static readonly StreamReader consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);

    private static int ReadInt()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static long ReadLong()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] ReadIntArray(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = ReadInt();
        return ans;
    }

    private static long[] ReadLongArray(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = ReadLong();
        return ans;
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (ans < 'a' || ans > 'z');

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            ans = consoleReader.Read();
        } while (ans >= 'a' && ans <= 'z');

        return s;
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
}


using System;

namespace CodeForces
{
	class A
	{
		static long gcd(long a, long b)
		{
			while (b != 0)
			{
				long temp = b;
				b = a % b;
				a = temp;
			}
			return a;
		}

		static long lcm(long m, long n)
		{
			return (m / gcd(m, n)) * n;
		}

		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			string[] d = s.Split(' ');
			long n = long.Parse(d[0]);
			int k = int.Parse(d[1]);
			int div = (int) Math.Pow(10, k);

			Console.WriteLine(lcm(n, div));
		}
	}
}


using System;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int s, v1, v2, t1, t2, a, b;
            s = Convert.ToInt32(str[0]);
            v1 = Convert.ToInt32(str[1]);
            v2 = Convert.ToInt32(str[2]);
            t1 = Convert.ToInt32(str[3]);
            t2 = Convert.ToInt32(str[4]);
            if (v1 * s + t1 * 2 < v2 * s + t2 * 2)
                Console.WriteLine("First");
            else if (v1 * s + t1 * 2 == v2 * s + t2 * 2)
                Console.WriteLine("Friendship");
            else
                Console.WriteLine("Second");
        }
    }
}


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

namespace DiceRolling
{
    class Program
    {
        static void Main(string[] args)
        {
            int q = int.Parse(Console.ReadLine());
            int[] a = new int[q];
            for (int i = 0; i < q; i++)
            {
                a[i] = int.Parse(Console.ReadLine()) / 2;
            }
            foreach (int i in a)
                Console.WriteLine(i);
            Console.ReadLine();
        }
    }
}


using System;
class Program
    {
        public static void Main(string[] args)
        {
            long[] dt;
            //string[] input = Console.In.ReadLine().Split(new char[] { '\t', ' ', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
            {
                dt = new long[3];
                string[] inp = Console.ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                dt[0] = long.Parse(inp[0]);
                dt[1] = long.Parse(inp[1]);
                dt[2] = 1L;
                if(dt[1]==4)
                {
                    dt[2] += (dt[0] - 1L) * (dt[0] - 2L) * dt[0] * (dt[0] - 3L) * 9L / 24L;
                    dt[1]--;
                }
            }
            {
                long temp = dt[0] * dt[0] - dt[0];
                dt[0]--;
                for (long temp2 = 2L, cntr = 2L; cntr <=dt[1];)
                {
                    dt[2] += ((temp * temp2 / cntr) / temp2);
                    temp *= --dt[0];
                    temp2 *= ++cntr;
                }
            }
            Console.WriteLine(dt[2]);
        }

    }


using System;

namespace Olymp
{
    class Program
    {

        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            if (n == 1) Console.WriteLine(1);
            else if (n == 2) Console.WriteLine(2);
            else
                Console.WriteLine(Numb(n));
        }

        static public long Numb(int n)
        {
            long max = n * (n - 1) * (n - 2) / GCD(n, n - 2);
            for (int q = 10;  q > 0; q--)
            {
                long t = n * (n - 1) * (n - 2) / GCD(n, n - 2);
                for (long i = n; i > n - 10 && i > 2; i--)

                    for (long j = i - 1; j > i - 11 && j > 1; j--)

                        for (long k = j - 1; k > i - 12 && k > 0; k--)

                            if ((i * j * k) / GCD(i, k) > t)
                                t = i * j * k / GCD(i, k);

                if (t > max) max = t;
            }
            return max;
        }
        public static long GCD(long a, long b)
        {
            if (b == 0) return a;
            else return GCD(b, a % b);
        }
    }
}


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

public class Matrix {
    public int Row, Col;
    private int[] Data;
    public Matrix(int row, int col) {
        this.Row = row;
        this.Col = col;
        this.Data = new int[Row * Col];
    }

    public int this[int row, int col] {
        set {
            Data[row * Col + col] = value;
        }
        get {
            return Data[row * Col + col];
        }
    }

    static public Matrix UnitMatrix(int n) {
        Matrix matrix = new Matrix(n, n);
        for (int i = 0; i < n; i++) {
            matrix[i, i] = 1;
        }
        return matrix;
    }

    static public Matrix operator +(Matrix A, Matrix B) {
        Matrix C = new Matrix(A.Row, A.Col);
        for (int i = 0; i < C.Data.Length; i++) {
            if (A.Data[i] == int.MaxValue || B.Data[i] == int.MaxValue)
                C.Data[i] = int.MaxValue;
            else
                C.Data[i] = A.Data[i] + B.Data[i];
        }
        return C;
    }

    static public Matrix operator -(Matrix A, Matrix B) {
        Matrix C = new Matrix(A.Row, A.Col);
        for (int i = 0; i < C.Data.Length; i++) {
            C.Data[i] = A.Data[i] - B.Data[i];
        }
        return C;
    }

    static public Matrix operator *(Matrix A, Matrix B) {
        Matrix C = new Matrix(A.Row, B.Col);
        for (int i = 0; i < A.Row; i++) {
            for (int j = 0; j < B.Col; j++) {
                C[i, j] = int.MaxValue;
                for (int k = 0; k < A.Col; k++) {
                    //C[i, j] += A[i, k] * B[k, j];
                    if (A[i, k] == int.MaxValue || B[k, j] == int.MaxValue) continue;
                    C[i, j] = Math.Min(C[i, j], A[i, k] + B[k, j]);
                }
            }
        }
        return C;
    }

    static public Matrix Pow(Matrix A, long n) {
        if (n == 0) return UnitMatrix(A.Row);
        Matrix result = A.Clone(), t = A.Clone(); n--;
        while (n > 0) {
            if ((n & 1) != 0) {
                result = result * t;
            }

            t = t * t;
            n >>= 1;
        }

        return result;
    }

    public Matrix Clone() {
        Matrix clone = new Matrix(Row, Col);
        clone.Data = Data.Clone() as int[];
        return clone;
    }
}

public partial class CodeForces {

    static void UpdateMin<T>(ref T x, T newValue) where T : IComparable<T> {
        if (x.CompareTo(newValue) > 0) x = newValue;
    }

    static public void Solve(TextReader cin, TextWriter cout) {
        var scanner = new Scanner(cin);
        int n = scanner.NextInt32();
        int m = scanner.NextInt32();
        var a = scanner.NextIntArray(n);
        var b = scanner.NextIntArray(n);
        int maxDepth = 2 * n + 1;
        var dp = new int[maxDepth, maxDepth];
        for (int i = 0; i < maxDepth; i++) {
            for (int j = 0; j < maxDepth; j++) {
                dp[i, j] = int.MaxValue;
            }
            dp[i, i] = 0;
        }
        for (int i = 0; i < n; i++) {
            var next = new int[maxDepth, maxDepth];
            for (int j = 0; j < maxDepth; j++) {
                for (int k = 0; k < maxDepth; k++) {
                    next[j, k] = int.MaxValue;
                }
            }
            for (int j = 0; j < maxDepth; j++) {
                for (int k = 0; k < maxDepth; k++) {
                    if (dp[j, k] == int.MaxValue) continue;
                    if (k + 1 < maxDepth)
                        UpdateMin(ref next[j, k + 1], dp[j, k] + a[i]);
                    if (k - 1 >= 0)
                        UpdateMin(ref next[j, k - 1], dp[j, k] + b[i]);
                }
            }

            dp = next;
        }

        /*for (int i = 0; i < maxDepth; i++) {
            for (int j = 0; j < maxDepth; j++) {
                Console.Error.Write(" " + dp[i, j]);
            }
            Console.Error.WriteLine();
        }*/

        Matrix M = new Matrix(maxDepth, maxDepth);

        for (int i = 0; i < maxDepth; i++) {
            for (int j = 0; j < maxDepth; j++) {
                M[i, j] = dp[i, j];
            }
        }

        Matrix A = M.Clone();

        A = Matrix.Pow(A, m);

        cout.WriteLine(A[0, 0]);
    }

    // PREWRITEN CODE BEGINS FROM HERE

    public static void Main(string[] args) {
#if ONLINE_JUDGE
        Solve(Console.In, Console.Out);
#else
        SampleTest();
#endif

    }

    static void SampleTest() {

        var Inputs = @"
2 6
1 2
2 1
------------
1 10000000
2
3
".Split(new[] { "------------" }, StringSplitOptions.None).Select(s => s.Trim()).ToArray();

        var Outputs = @"
12
------------
25000000
".Split(new[] { "------------" }, StringSplitOptions.None).Select(s => s.Trim()).ToArray();

        int caseNo = 1;
        int all = 0, passed = 0;
        foreach (var sample in Inputs.Zip(Outputs, (Input, Output) => new { Input, Output })) {
            var stopWatch = new System.Diagnostics.Stopwatch();
            var writer = new StringWriter();
            stopWatch.Start();
            Solve(new StringReader(sample.Input), writer);
            stopWatch.Stop();
            string time = "";
            if (stopWatch.ElapsedMilliseconds >= 10) {
                time = String.Format("({0} ms)", stopWatch.ElapsedMilliseconds);
            }
            var result = writer.ToString().Trim();
            all++;
            if (result == sample.Output) {
                Console.WriteLine("Sample {0} .... Passed {1}", caseNo++, time);
                passed++;
            } else {
                Console.WriteLine("Sample {0} .... Failed", caseNo++, time);
                Console.WriteLine("Input : ");
                Console.WriteLine("{0}", sample.Input);
                Console.WriteLine("Expected : ");
                Console.WriteLine("{0}", sample.Output);
                Console.WriteLine("Received : ");
                Console.WriteLine("{0}", result);
            }
        }

        Console.WriteLine(" {0} / {1} Passed !!", passed, all);

        Solve(Console.In, Console.Out);
    }

}

public class Scanner {
    private TextReader Reader;
    private Queue<String> TokenQueue = new Queue<string>();
    private CultureInfo ci = new CultureInfo("en-US");

    public Scanner()
        : this(Console.In) {
    }

    public Scanner(TextReader reader) {
        this.Reader = reader;
    }

    public char NextChar() { return Next().Single(); }
    public int NextInt32() { return Int32.Parse(Next(), ci); }
    public long NextInt64() { return Int64.Parse(Next(), ci); }
    public double NextDouble() { return double.Parse(Next(), ci); }
    public string[] NextArray(int size) {
        var array = new string[size];
        for (int i = 0; i < size; i++) array[i] = Next();
        return array;
    }
    public int[] NextIntArray(int size) {
        var array = new int[size];
        for (int i = 0; i < size; i++) array[i] = NextInt32();
        return array;
    }

    public long[] NextInt64Array(int size) {
        var array = new long[size];
        for (int i = 0; i < size; i++) array[i] = NextInt64();
        return array;
    }

    public String Next() {
        if (!TokenQueue.Any()) {
            if (!StockTokens()) throw new InvalidOperationException();
        }
        return TokenQueue.Dequeue();
    }

    public bool HasNext() {
        if (TokenQueue.Count > 0)
            return true;
        return StockTokens();
    }

    private bool StockTokens() {
        while (true) {
            var line = Reader.ReadLine();
            if (line == null) return false;
            var tokens = line.Trim().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToArray();
            if (tokens.Length == 0) continue;
            foreach (var token in tokens)
                TokenQueue.Enqueue(token);
            return true;
        }
    }
}