A string is called bracket sequence if it does not contain any characters other than "(" and ")". A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters "+" and "1" into this sequence. For example, "", "(())" and "()()" are regular bracket sequences; "))" and ")((" are bracket sequences (but not regular ones), and "(a)" and "(1)+(1)" are not bracket sequences at all.You have a number of strings; each string is a bracket sequence of length $$$2$$$. So, overall you have $$$cnt_1$$$ strings "((", $$$cnt_2$$$ strings "()", $$$cnt_3$$$ strings ")(" and $$$cnt_4$$$ strings "))". You want to write all these strings in some order, one after another; after that, you will get a long bracket sequence of length $$$2(cnt_1 + cnt_2 + cnt_3 + cnt_4)$$$. You wonder: is it possible to choose some order of the strings you have such that you will get a regular bracket sequence? Note that you may not remove any characters or strings, and you may not add anything either.

The input consists of four lines, $$$i$$$-th of them contains one integer $$$cnt_i$$$ ($$$0 \le cnt_i \le 10^9$$$).

Print one integer: $$$1$$$ if it is possible to form a regular bracket sequence by choosing the correct order of the given strings, $$$0$$$ otherwise.

NoteIn the first example it is possible to construct a string "(())()(()((()()()())))", which is a regular bracket sequence.In the second example it is possible to construct a string "", which is a regular bracket sequence.

/* Date: 05.03.2019 * Time: 21:45 */
//

/*
�	fflush(stdout) � ����� C++;
�	System.out.flush() � Java;
�	stdout.flush() � Python;
�	flush(output) � Pascal;

*/

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

class Example
{
	public static void Swap (ref int a, ref int b)
	{
		int c = a; a = b; b = c;
	}
	public static void Main (string[] args)
	{
# if ( ! ONLINE_JUDGE )
		StreamReader sr = new StreamReader ("C:\\TRR\\2019\\Task\\07 Codeforces\\037\\A.TXT");
		StreamWriter sw = new StreamWriter ("C:\\TRR\\2019\\Task\\07 Codeforces\\037\\A.OUT");
# endif

		NumberFormatInfo nfi = NumberFormatInfo.InvariantInfo;

		int n1, n2, n3, n4;

# if ( ONLINE_JUDGE )
		n1 = int.Parse (Console.ReadLine ());
		n2 = int.Parse (Console.ReadLine ());
		n3 = int.Parse (Console.ReadLine ());
		n4 = int.Parse (Console.ReadLine ());
# else
		n1 = int.Parse (sr.ReadLine ());
		n2 = int.Parse (sr.ReadLine ());
		n3 = int.Parse (sr.ReadLine ());
		n4 = int.Parse (sr.ReadLine ());
		sw.WriteLine ("*** n1 = " + n1);
		sw.WriteLine ("*** n2 = " + n2);
		sw.WriteLine ("*** n3 = " + n3);
		sw.WriteLine ("*** n4 = " + n4);
# endif

		int k = 0;
		if ( n1 == n4 && (n3 == 0 || n3 > 0 && n1 > 0) )
			k = 1;

# if ( ONLINE_JUDGE )
		Console.WriteLine (k);
# else
		sw.WriteLine (k);
		sw.Close ();
# endif

	}
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d;
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            c = int.Parse(Console.ReadLine());
            d = int.Parse(Console.ReadLine());
            if ((c>0)&&(a==0))
            {
                Console.Write(0);
                return;
            }
            if(d!=a)
            {
                Console.Write(0);
                return;
            }
            Console.Write(1);
            return;
        }
    }
}

using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int count1 = int.Parse(Console.ReadLine());
            int count2 = int.Parse(Console.ReadLine());
            int count3 = int.Parse(Console.ReadLine());
            int count4 = int.Parse(Console.ReadLine());
            int result = 1;

            if (count1 != count4 || (count3 > 0 && count1 == 0))
                result = 0;

            Console.WriteLine($"{result}");
            Console.ReadLine();
        }
    }
}

using System;
namespace BasicProgramming
{
    class Program
    {
        static void Main(string[] args)
        {
        int A = int.Parse(Console.ReadLine());
		int B = int.Parse(Console.ReadLine());
		int C = int.Parse(Console.ReadLine());
		int D = int.Parse(Console.ReadLine());
		int ans = 1;
		if(A*2+B+C != B+C+D*2){
			ans = 0;
		}
		if(C>0 && A==0){
			ans = 0;
		}
		Console.WriteLine(ans);

        }
    }
}

using System;

namespace Skyscraper
{
    class Program
    {
        static void Main()
        {
            int t1 = Convert.ToInt32(Console.ReadLine());
            int t2 = Convert.ToInt32(Console.ReadLine());
            int t3 = Convert.ToInt32(Console.ReadLine());
            int t4 = Convert.ToInt32(Console.ReadLine());
            if (t3 > 0)
                if (t1 == 0)
                {
                    Console.WriteLine("0");
                    return;
        }
            if (t1 != t4)
            {
                Console.WriteLine("0");
                return;
            }
            Console.WriteLine("1");
        }
    }
}

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

namespace ConsoleApp56
{
    class Program
    {
        static void Main(string[] args)
        {

            long First = long.Parse(Console.ReadLine());
            long Second = long.Parse(Console.ReadLine());
            long Three = long.Parse(Console.ReadLine());
            long Four = long.Parse(Console.ReadLine());

            if (First == 0 && Four == 0 && Three != 0) Console.WriteLine("0");
              else if (First != Four) Console.WriteLine("0");
            else Console.WriteLine("1");

        }

    }
}

using System;
using System.Collections.Generic;
using static System.Linq.Enumerable;
using static CompetitiveCSharp.IO;

namespace CompetitiveCSharp
{
    static class IO
    {
        static Dummy dummy = new Dummy();
        static System.Text.StringBuilder builder = new System.Text.StringBuilder();
        class Dummy
        {
            ~Dummy()
            {
                Flush();
            }
        }
        static public void WriteLine(object str)
        {
            Write(str);
            builder.AppendLine();
        }
        static public void WriteLine()
        {
            builder.AppendLine();
        }
        static public void Write(object str)
        {
            builder.Append(str);
        }
        static public void Flush()
        {
            Console.Write(builder);
            builder.Clear();
        }
        static public string ReadLine()
        {
            return Console.ReadLine();
        }
        static public int ReadInt()
        {
            return int.Parse(ReadLine());
        }
    }
    static class Program
    {
        static T[] ReadArray<T>(Func<string, T> parser)
        {
            return ReadLine().Split(' ').Select(parser).ToArray();
        }
        static (T, T) ReadTuple2<T>(Func<string, T> parser)
        {
            var a = ReadArray(parser);
            return (a[0], a[1]);
        }
        static bool Run(long[] data)
        {
            if (data[0] != data[3])
            {
                return false;
            }
            return data[0] != 0 || data[2] == 0;
        }
        static void Main(string[] args)
        {
            var data = new long[4];
            foreach(var i in Range(0, 4))
            {
                data[i] = long.Parse(ReadLine());
            }
            WriteLine(Run(data) ? 1 : 0);
        }
    }
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int a ,b, c, d,m,n;
            a =int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            c = int.Parse(Console.ReadLine());
            d = int.Parse(Console.ReadLine());
            m = (a * 2) + (b) + (c);
            n = (d * 2) + (b) + (c);
            if ((a == 0 && d == 0 && c != 0) || m!= n)
            {
                    Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1);
            }

        }
    }
}

//using MetadataExtractor;
//using MetadataExtractor.Formats.Exif;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces
{
    public static class MainClass
    {

        static int ReadIntLine()
        {
            return int.Parse(Console.ReadLine());
        }

        static void ReadInt(ref int a)
        {
            a = ReadIntArrayLine()[0];
        }

        static void ReadInts(ref int a, ref int b)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1];
        }

        static void ReadInts(ref int a, ref int b, ref int c)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];
        }

        static int[] ReadIntArrayLine()
        {
            char[] sep = { ' ' };
            return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static void PrintLn(object obj)
        {
            Console.WriteLine(obj.ToString());
        }

        /*public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }*/

        public static void PrintLnCollection<T>(IEnumerable<T> col)
        {
            PrintLn(string.Join(" ", col));
        }

        public static void PrintLn(params object[] v)
        {
            PrintLnCollection(v);
        }

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

        public static string MySubstring(this string str, int start, int finish)
        {
            if (start > finish) return "";
            return str.Substring(start, finish - start + 1);
        }

        public static string Reverse(this string str)
        {
            if (str == null) return null;

            return new string(str.ToArray().Reverse().ToArray());
        }
        public static bool IsInRange(this int a, int lb, int ub)
        {
            return (a >= lb) && (a <= ub);
        }

        private static void mergeDS(int i, int j, int[] a)
        {
            int t = a[j];
            for (int ii = 0; ii < a.Length; ii++)
            {
                if (a[ii] == t)
                    a[ii] = a[i];
            }
        }

        private static T MyMax<T>(params T[] a)
        {
            return a.Max();
        }

        private static T MyMin<T>(params T[] a)
        {
            return a.Min();
        }

        private static int[] GetPrimesLessThan(int x)
        {
            if (x < 2)
                return new int[0];

            int[] a = new int[x];

            a[0] = 1; a[1] = 1;

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    for (int j = 2 * i; j < a.Length; j += i)
                    {
                        a[j] = 1;
                    }
            }

            var abc = new List<int>(x);

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    abc.Add(i);
            }

            return abc.ToArray();
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target == a[mid])
                return mid;
            else if (target < a[mid])
                return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindNearestLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int target)
        {
            return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

        private static int FindRightMostLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target < a[mid])
                return FindRightMostLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindRightMostLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindRightMostLEQElementInTheArray(int[] a, int target)
        {
            return FindRightMostLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

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

        //----------------------------------------------------------------------------

        static string GetSha1(string filePath)
        {
            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            using (BufferedStream bs = new BufferedStream(fs))
            {
                using (SHA1Managed sha1 = new SHA1Managed())
                {
                    byte[] hash = sha1.ComputeHash(bs);
                    StringBuilder formatted = new StringBuilder(2 * hash.Length);
                    foreach (byte b in hash)
                    {
                        formatted.AppendFormat("{0:X2}", b);
                    }

                    return formatted.ToString();
                }
            }
        }

        static bool canFit(int a1, int b1, int a2, int b2)
        {
            int[] r1 = { a1, b1 };
            int[] r2 = { a2, b2 };

            Array.Sort(r1);
            Array.Sort(r2);

            bool ans = (r1[0] <= r2[0]) && (r1[1] <= r2[1]);

            return ans;

        }

        class Pair
        {
            public int first { get; set; }
            public int second { get; set; }
        }

        class Coord
        {
            public int x;
            public int y;
            public double d;
        }

        public static double dist(int x1,int y1,int x2,int y2)
        {
            int dx = x2 - x1;
            int dy = y2 - y1;

            return Math.Sqrt(dx * dx + dy * dy);

        }
        static void Main(string[] args)
        {
           int n1 = ReadIntLine();
           int n2 = ReadIntLine();
           int n3 = ReadIntLine();
           int n4 = ReadIntLine();

           if (n1 != n4){PrintLn(0);return;}
           if (n3>0 && n1==0) {PrintLn(0);return;}
           PrintLn(1);

        }

    }

}

using System;

namespace CSharp
{
    class _1132A
    {
        public static void Main()
        {
            int cnt1 = int.Parse(Console.ReadLine());
            int cnt2 = int.Parse(Console.ReadLine());
            int cnt3 = int.Parse(Console.ReadLine());
            int cnt4 = int.Parse(Console.ReadLine());

            Console.WriteLine(cnt1 == cnt4 && (cnt1 > 0 || cnt3 == 0) ? 1 : 0);
        }
    }
}

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

namespace Contest
{
    class Scanner
    {
        public Scanner()
        {
            _stream = new StreamReader(Console.OpenStandardInput());
            _pos = 0;
            _line = new string[0];
            _separator = ' ';
        }

        private char _separator;
        private StreamReader _stream;
        private int _pos;
        private string[] _line;

        #region get a element

        public string Next()
        {
            if (_pos >= _line.Length)
            {
                _line = _stream.ReadLine().Split(_separator);
                _pos = 0;
            }

            return _line[_pos++];
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        #endregion

        #region convert array

        private int[] ToIntArray(string[] array)
        {
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        private long[] ToLongArray(string[] array)
        {
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }

        private double[] ToDoubleArray(string[] array)
        {
            var result = new double[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = double.Parse(array[i]);
            }

            return result;
        }

        #endregion

        #region get row elements

        #region get array

        public string[] Array()
        {
            if (_pos >= _line.Length)
                _line = _stream.ReadLine().Split(_separator);

            _pos = _line.Length;
            return _line;
        }

        public int[] IntArray()
        {
            return ToIntArray(Array());
        }

        public long[] LongArray()
        {
            return ToLongArray(Array());
        }

        public double[] DoubleArray()
        {
            return ToDoubleArray(Array());
        }

        #endregion

        #region get 2~4 elements

        public void GetRow(out string a, out string b)
        {
            a = Next();
            b = Next();
        }

        public void GetRow(out string a, out string b, out string c)
        {
            a = Next();
            b = Next();
            c = Next();
        }

        public void GetRow(out string a, out string b, out string c, out string d)
        {
            a = Next();
            b = Next();
            c = Next();
            d = Next();
        }

        public void GetIntRow(out int a, out int b)
        {
            a = NextInt();
            b = NextInt();
        }

        public void GetIntRow(out int a, out int b, out int c)
        {
            a = NextInt();
            b = NextInt();
            c = NextInt();
        }

        public void GetIntRow(out int a, out int b, out int c, out int d)
        {
            a = NextInt();
            b = NextInt();
            c = NextInt();
            d = NextInt();
        }

        public void GetLongRow(out long a, out long b)
        {
            a = NextLong();
            b = NextLong();
        }

        public void GetLongRow(out long a, out long b, out long c)
        {
            a = NextLong();
            b = NextLong();
            c = NextLong();
        }

        public void GetLongRow(out long a, out long b, out long c, out long d)
        {
            a = NextLong();
            b = NextLong();
            c = NextLong();
            d = NextLong();
        }

        public void GetDoubleRow(out double a, out double b)
        {
            a = NextDouble();
            b = NextDouble();
        }

        public void GetDoubleRow(out double a, out double b, out double c)
        {
            a = NextDouble();
            b = NextDouble();
            c = NextDouble();
        }

        public void GetDoubleRow(out double a, out double b, out double c, out double d)
        {
            a = NextDouble();
            b = NextDouble();
            c = NextDouble();
            d = NextDouble();
        }

        #endregion

        #endregion

        #region get 2~4 column elements

        public void GetColumn(int n, out string[] a)
        {
            a = new string[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = Next();
            }
        }

        public void GetColumn(int n, out string[] a, out string[] b)
        {
            a = new string[n];
            b = new string[n];
            for (int i = 0; i < n; i++)
            {
                GetRow(out a[i], out b[i]);
            }
        }

        public void GetColumn(int n, out string[] a, out string[] b, out string[] c)
        {
            a = new string[n];
            b = new string[n];
            c = new string[n];
            for (int i = 0; i < n; i++)
            {
                GetRow(out a[i], out b[i], out c[i]);
            }
        }

        public void GetColumn(int n, out string[] a, out string[] b, out string[] c, out string[] d)
        {
            a = new string[n];
            b = new string[n];
            c = new string[n];
            d = new string[n];
            for (int i = 0; i < n; i++)
            {
                GetRow(out a[i], out b[i], out c[i], out d[i]);
            }
        }

        public void GetIntColumn(int n, out int[] a)
        {
            string[] sa;
            GetColumn(n, out sa);
            a = ToIntArray(sa);
        }

        public void GetIntColumn(int n, out int[] a, out int[] b)
        {
            string[] sa, sb;
            GetColumn(n, out sa, out sb);
            a = ToIntArray(sa);
            b = ToIntArray(sb);
        }

        public void GetIntColumn(int n, out int[] a, out int[] b, out int[] c)
        {
            string[] sa, sb, sc;
            GetColumn(n, out sa, out sb, out sc);
            a = ToIntArray(sa);
            b = ToIntArray(sb);
            c = ToIntArray(sc);
        }

        public void GetIntColumn(int n, out int[] a, out int[] b, out int[] c, out int[] d)
        {
            string[] sa, sb, sc, sd;
            GetColumn(n, out sa, out sb, out sc, out sd);
            a = ToIntArray(sa);
            b = ToIntArray(sb);
            c = ToIntArray(sc);
            d = ToIntArray(sd);
        }

        public void GetLongColumn(int n, out long[] a)
        {
            string[] sa;
            GetColumn(n, out sa);
            a = ToLongArray(sa);
        }

        public void GetLongColumn(int n, out long[] a, out long[] b)
        {
            string[] sa, sb;
            GetColumn(n, out sa, out sb);
            a = ToLongArray(sa);
            b = ToLongArray(sb);
        }

        public void GetLongColumn(int n, out long[] a, out long[] b, out long[] c)
        {
            string[] sa, sb, sc;
            GetColumn(n, out sa, out sb, out sc);
            a = ToLongArray(sa);
            b = ToLongArray(sb);
            c = ToLongArray(sc);
        }

        public void GetLongColumn(int n, out long[] a, out long[] b, out long[] c, out long[] d)
        {
            string[] sa, sb, sc, sd;
            GetColumn(n, out sa, out sb, out sc, out sd);
            a = ToLongArray(sa);
            b = ToLongArray(sb);
            c = ToLongArray(sc);
            d = ToLongArray(sd);
        }

        public void GetDoubleColumn(int n, out double[] a)
        {
            string[] sa;
            GetColumn(n, out sa);
            a = ToDoubleArray(sa);
        }

        public void GetDoubleColumn(int n, out double[] a, out double[] b)
        {
            string[] sa, sb;
            GetColumn(n, out sa, out sb);
            a = ToDoubleArray(sa);
            b = ToDoubleArray(sb);
        }

        public void GetDoubleColumn(int n, out double[] a, out double[] b, out double[] c)
        {
            string[] sa, sb, sc;
            GetColumn(n, out sa, out sb, out sc);
            a = ToDoubleArray(sa);
            b = ToDoubleArray(sb);
            c = ToDoubleArray(sc);
        }

        public void GetDoubleColumn(int n, out double[] a, out double[] b, out double[] c, out double[] d)
        {
            string[] sa, sb, sc, sd;
            GetColumn(n, out sa, out sb, out sc, out sd);
            a = ToDoubleArray(sa);
            b = ToDoubleArray(sb);
            c = ToDoubleArray(sc);
            d = ToDoubleArray(sd);
        }

        #endregion

        #region get matrix

        public string[][] GetMatrix(int h)
        {
            string[][] result = new string[h][];
            for (int i = 0; i < h; i++)
            {
                result[i] = Array();
            }

            return result;

        }

        public int[][] GetIntMatrix(int h)
        {
            int[][] result = new int[h][];
            for (int i = 0; i < h; i++)
            {
                result[i] = IntArray();
            }

            return result;
        }

        public long[][] GetLongMatrix(int h)
        {
            long[][] result = new long[h][];
            for (int i = 0; i < h; i++)
            {
                result[i] = LongArray();
            }

            return result;
        }

        public double[][] GetDoubleMatrix(int h)
        {
            double[][] result = new double[h][];
            for (int i = 0; i < h; i++)
            {
                result[i] = DoubleArray();
            }

            return result;
        }

        public char[][] GetCharMatrix(int h)
        {
            char[][] result = new char[h][];
            for (int i = 0; i < h; i++)
            {
                result[i] = Next().ToCharArray();
            }

            return result;
        }

        #endregion
    }

    class Program
    {

        public void Solve()
        {
            var sc = new Scanner();
            int c1, c2, c3, c4;
            sc.GetIntRow(out c1, out c2, out c3, out c4);

            // ((, (), )(, ))

            if (c3 > 0)
            {
                if (c1 <= 0)
                {
                    Console.WriteLine(0);
                    return;
                }
            }

            if (c1 != c4)
            {
                Console.WriteLine(0);
                return;
            }

            Console.WriteLine(1);

        }

        static void Main(string[] args) => new Program().Solve();
    }
}

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

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1 = Convert.ToInt32(Console.ReadLine());
            int c2 = Convert.ToInt32(Console.ReadLine());
            int c3 = Convert.ToInt32(Console.ReadLine());
            int c4 = Convert.ToInt32(Console.ReadLine());
            if(c1 == 0)
            {
                if (c3 == 0 && c4 == 0)
                    Console.WriteLine(1);
                else
                    Console.WriteLine(0);
            }
            else if(c4 == c1)
                Console.WriteLine(1);
            else
                Console.WriteLine(0);
        }
    }
}

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

namespace Test
{
    class IOHelper : IDisposable
    {
        StreamReader reader;
        StreamWriter writer;

        public IOHelper(string inputFile, string outputFile, Encoding encoding)
        {
            StreamReader iReader;
            StreamWriter oWriter;
            if (inputFile == null)
                iReader = new StreamReader(Console.OpenStandardInput(), encoding);
            else
                iReader = new StreamReader(inputFile, encoding);

            if (outputFile == null)
                oWriter = new StreamWriter(Console.OpenStandardOutput(), encoding);
            else
                oWriter = new StreamWriter(outputFile, false, encoding);

            reader = iReader;
            writer = oWriter;

            curLine = new string[] { };
            curTokenIdx = 0;
        }

        string[] curLine;
        int curTokenIdx;

        char[] whiteSpaces = new char[] { ' ', '\t', '\r', '\n' };

        public string ReadNextToken()
        {
            if (curTokenIdx >= curLine.Length)
            {
                //Read next line
                string line = reader.ReadLine();
                if (line != null)
                    curLine = line.Split(whiteSpaces, StringSplitOptions.RemoveEmptyEntries);
                else
                    curLine = new string[] { };
                curTokenIdx = 0;
            }

            if (curTokenIdx >= curLine.Length)
                return null;

            return curLine[curTokenIdx++];
        }

        public int ReadNextInt()
        {
            return int.Parse(ReadNextToken());
        }

        public double ReadNextDouble()
        {
            var nextToken = ReadNextToken();
            var result = 0.0;
            nextToken = nextToken.Replace(".", System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator);
            result = double.Parse(nextToken);
            return result;
        }

        public void Write(string stringToWrite)
        {
            writer.Write(stringToWrite);
        }

        public void WriteLine(string stringToWrite)
        {
            writer.WriteLine(stringToWrite);
        }

        public void WriteLine(double valueToWrite)
        {
			writer.WriteLine(valueToWrite.ToString("F8"));
        }

        public void Dispose()
        {
            try
            {
                if (reader != null)
                {
                    reader.Dispose();
                }
                if (writer != null)
                {
                    writer.Dispose();
                }
            }
            catch { };
        }

        public void Flush()
        {
            if (writer != null)
            {
                writer.Flush();
            }
        }
    }

    class Program
    {
        protected IOHelper ioHelper;

        long cnt1, cnt2, cnt3, cnt4;

        public void Solve()
        {
            cnt1 = long.Parse(ioHelper.ReadNextToken());
            cnt2 = long.Parse(ioHelper.ReadNextToken());
            cnt3 = long.Parse(ioHelper.ReadNextToken());
            cnt4 = long.Parse(ioHelper.ReadNextToken());

            bool bPosib = true;
            long delta = cnt1 * 2;
            if (delta <= 0 && cnt3 > 0)
                bPosib = false;
            delta -= cnt4 * 2;
            if (delta != 0)
                bPosib = false;

            if (bPosib)
                ioHelper.WriteLine("1");
            else
                ioHelper.WriteLine("0");

            ioHelper.Flush();

            //Console.ReadKey();
        }

        public Program(string inputFile, string outputFile)
        {
            ioHelper = new IOHelper(inputFile, outputFile, Encoding.Default);
            Solve();
            ioHelper.Dispose();
        }

        static void Main(string[] args)
        {
            Program myProgram = new Program(null, null);
        }
    }
}

using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int A = int.Parse(Console.ReadLine());
		int B = int.Parse(Console.ReadLine());
		int C = int.Parse(Console.ReadLine());
		int D = int.Parse(Console.ReadLine());
		int ans = 1;
		if(A*2+B+C != B+C+D*2){
			ans = 0;
		}
		if(C>0 && A==0){
			ans = 0;
		}
		Console.WriteLine(ans);
	}
}

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

namespace Regular_Bracket_Sequence
{
    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)
        {
            writer.WriteLine(Solve() ? "1" : "0");
            writer.Flush();
        }

        private static bool Solve()
        {
            int n1 = Next();
            int n2 = Next();
            int n3 = Next();
            int n4 = Next();

            return n1 == n4 && (n3 > 0 && n1 != 0 || n3 == 0);
        }

        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.Threading.Tasks;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            long a = long.Parse(Console.ReadLine());
            long b = long.Parse(Console.ReadLine());
            long c = long.Parse(Console.ReadLine());
            long d = long.Parse(Console.ReadLine());

            if (a == d)
            {
                if (a > 0)
                {
                    Console.WriteLine(1);
                    return;
                }
                if (c == 0)
                {
                    Console.WriteLine(1);
                    return;
                }
            }
            Console.WriteLine(0);
            return;
        }
    }
}

/*
csc -debug A.cs && mono --debug A.exe <<< "3
1
4
3"
*/

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

public class HelloWorld {
    public static void SolveCodeForces() {
        var A = cin.NextInt();
        var B = cin.NextInt();
        var C = cin.NextInt();
        var D = cin.NextInt();

        if (A + C + D == 0) {
            System.Console.WriteLine(1);
            return;
        }

        if (A == 0) {
            System.Console.WriteLine(0);
            return;
        }

        if (D != A) {
            System.Console.WriteLine(0);
            return;
        }

        System.Console.WriteLine(1);
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // System.Console.Write(cout.ToString());
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }

    public static IEnumerable<int> IndicesWhere<T>(this IEnumerable<T> seq, Func<T, bool> cond) {
        var i = 0;
        foreach (var item in seq) {
            if (cond(item)) yield return i;
            i++;
        }
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

using System;
using System.Collections.Generic;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1 = Convert.ToInt32(Console.ReadLine());//((
            int c2 = Convert.ToInt32(Console.ReadLine());//()
            int c3 = Convert.ToInt32(Console.ReadLine());//)(
            int c4 = Convert.ToInt32(Console.ReadLine());//))

            int sumo1 = c1 * 2;
            int sumo3 = c3;
            int sumo4 = c4 * 2;

            if (sumo1==sumo4&&sumo3==0) {

                Console.WriteLine("1");

            }
            else if(sumo1 == sumo4 && sumo3> 0&&sumo1>0)
                Console.WriteLine("1");
            else
                Console.WriteLine("0");
        }
    }
}

using System;
using System.Collections.Generic;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1 = Convert.ToInt32(Console.ReadLine());//((
            int c2 = Convert.ToInt32(Console.ReadLine());//()
            int c3 = Convert.ToInt32(Console.ReadLine());//)(
            int c4 = Convert.ToInt32(Console.ReadLine());//))

            int sumo1 = c1 * 2;
            int sumo3 = c3;
            int sumo4 = c4 * 2;

            if (sumo1==sumo4&&sumo3<=sumo1+1) {
                Console.WriteLine("1");

            }
            else
                Console.WriteLine("0");
        }
    }
}

using System;
using System.Collections.Generic;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1 = Convert.ToInt32(Console.ReadLine());//((
            int c2 = Convert.ToInt32(Console.ReadLine());//()
            int c3 = Convert.ToInt32(Console.ReadLine());//)(
            int c4 = Convert.ToInt32(Console.ReadLine());//))

            int sumo1 = c1 * 2;
            int sumo3 = c3;
            int sumo4 = c4 * 2;

            if (sumo1==sumo4&&sumo3<sumo1) {
                Console.WriteLine("1");

            }
            else
                Console.WriteLine("0");
        }
    }
}

using System;
using System.Collections.Generic;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1 = Convert.ToInt32(Console.ReadLine());//((
            int c2 = Convert.ToInt32(Console.ReadLine());//()
            int c3 = Convert.ToInt32(Console.ReadLine());//)(
            int c4 = Convert.ToInt32(Console.ReadLine());//))

            int sumo1 = c1 * 2;
            int sumo3 = c3;
            int sumo4 = c4 * 2;

            if (sumo1==sumo4) {
                Console.WriteLine("1");

            }
            else
                Console.WriteLine("0");
        }
    }
}

using System;
using System.Collections.Generic;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1 = Convert.ToInt32(Console.ReadLine());//((
            int c2 = Convert.ToInt32(Console.ReadLine());//()
            int c3 = Convert.ToInt32(Console.ReadLine());//)(
            int c4 = Convert.ToInt32(Console.ReadLine());//))

            string str1 = new string ('(', c1*2);
            string str2 = "";// new string ("()", c2);
            string str3 = ""; //new string (")(", c3);
            string str4 = new string (')', c4);

            for (int i = 0; i < c2; i++)
            {
                str2 += "()";

            }

            for (int i = 0; i < c3; i++)
            {
                str3 += ")(";
            }
      //      Console.WriteLine(str1);
        //    Console.WriteLine(str2);
        //    Console.WriteLine(str3);
        //    Console.WriteLine(str4);

            int sumo = 0;

            int sum = 0;

            string strcom = str1 + str2 + str3 + str4;
         //   Console.WriteLine(strcom);

            foreach (char n in strcom) {
                if (n == '(')
                {
                    sumo = sumo + 1;
                }
                else if (n == ')' && sumo > 0)
                {
                    sum = sum + 1;
                    sumo = sumo - 1;
                }
            }

            if (strcom.Length == sum * 2) {
                Console.WriteLine("1");

            }
            else
                Console.WriteLine("0");
        }
    }
}

using System;
using System.Collections.Generic;
using static System.Linq.Enumerable;
using static CompetitiveCSharp.IO;

namespace CompetitiveCSharp
{
    static class IO
    {
        static Dummy dummy = new Dummy();
        static System.Text.StringBuilder builder = new System.Text.StringBuilder();
        class Dummy
        {
            ~Dummy()
            {
                Flush();
            }
        }
        static public void WriteLine(object str)
        {
            Write(str);
            builder.AppendLine();
        }
        static public void WriteLine()
        {
            builder.AppendLine();
        }
        static public void Write(object str)
        {
            builder.Append(str);
        }
        static public void Flush()
        {
            Console.Write(builder);
            builder.Clear();
        }
        static public string ReadLine()
        {
            return Console.ReadLine();
        }
        static public int ReadInt()
        {
            return int.Parse(ReadLine());
        }
    }
    static class Program
    {
        static T[] ReadArray<T>(Func<string, T> parser)
        {
            return ReadLine().Split(' ').Select(parser).ToArray();
        }
        static (T, T) ReadTuple2<T>(Func<string, T> parser)
        {
            var a = ReadArray(parser);
            return (a[0], a[1]);
        }
        static bool Run(long[] data)
        {
            if(data[0]!=data[3])
            {
                return false;
            }
            return data[2] == 0;
        }
        static void Main(string[] args)
        {
            var data = new long[4];
            foreach(var i in Range(0, 4))
            {
                data[i] = long.Parse(ReadLine());
            }
            WriteLine(Run(data) ? 1 : 0);
        }
    }
}

using System;
using System.Collections.Generic;
using static System.Linq.Enumerable;
using static CompetitiveCSharp.IO;

namespace CompetitiveCSharp
{
    static class IO
    {
        static Dummy dummy = new Dummy();
        static System.Text.StringBuilder builder = new System.Text.StringBuilder();
        class Dummy
        {
            ~Dummy()
            {
                Flush();
            }
        }
        static public void WriteLine(object str)
        {
            Write(str);
            builder.AppendLine();
        }
        static public void WriteLine()
        {
            builder.AppendLine();
        }
        static public void Write(object str)
        {
            builder.Append(str);
        }
        static public void Flush()
        {
            Console.Write(builder);
            builder.Clear();
        }
        static public string ReadLine()
        {
            return Console.ReadLine();
        }
        static public int ReadInt()
        {
            return int.Parse(ReadLine());
        }
    }
    static class Program
    {
        static T[] ReadArray<T>(Func<string, T> parser)
        {
            return ReadLine().Split(' ').Select(parser).ToArray();
        }
        static (T, T) ReadTuple2<T>(Func<string, T> parser)
        {
            var a = ReadArray(parser);
            return (a[0], a[1]);
        }
        static bool Run(long[] data)
        {
            return data[0] == data[3];
        }
        static void Main(string[] args)
        {
            var data = new long[4];
            foreach(var i in Range(0, 4))
            {
                data[i] = long.Parse(ReadLine());
            }
            WriteLine(Run(data) ? 1 : 0);
        }
    }
}

using System;
using System.Collections.Generic;
using static System.Linq.Enumerable;
using static CompetitiveCSharp.IO;

namespace CompetitiveCSharp
{
    static class IO
    {
        static Dummy dummy = new Dummy();
        static System.Text.StringBuilder builder = new System.Text.StringBuilder();
        class Dummy
        {
            ~Dummy()
            {
                Flush();
            }
        }
        static public void WriteLine(object str)
        {
            Write(str);
            builder.AppendLine();
        }
        static public void WriteLine()
        {
            builder.AppendLine();
        }
        static public void Write(object str)
        {
            builder.Append(str);
        }
        static public void Flush()
        {
            Console.Write(builder);
            builder.Clear();
        }
        static public string ReadLine()
        {
            return Console.ReadLine();
        }
        static public int ReadInt()
        {
            return int.Parse(ReadLine());
        }
    }
    static class Program
    {
        static T[] ReadArray<T>(Func<string, T> parser)
        {
            return ReadLine().Split(' ').Select(parser).ToArray();
        }
        static (T, T) ReadTuple2<T>(Func<string, T> parser)
        {
            var a = ReadArray(parser);
            return (a[0], a[1]);
        }
        static bool Run(long[] data)
        {
            if (data[0] != data[3])
            {
                return false;
            }
            return data[2] != 0;
        }
        static void Main(string[] args)
        {
            var data = new long[4];
            foreach(var i in Range(0, 4))
            {
                data[i] = long.Parse(ReadLine());
            }
            WriteLine(Run(data) ? 1 : 0);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            if (a == d)
            {
                Console.WriteLine(1);
                return;
            }
            Console.WriteLine(0);
            return;
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            if (a == d && a > 0)
            {
                Console.WriteLine(1);
                return;
            }
            Console.WriteLine(0);
            return;
        }
    }
}

using System;
using System.Collections.Generic;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1=Convert.ToInt32(Console.ReadLine());//((
            int c2=Convert.ToInt32(Console.ReadLine());//()
            int c3=Convert.ToInt32(Console.ReadLine());//)(
            int c4=Convert.ToInt32(Console.ReadLine());//))

            int sumo = 0;
            int sumc = 0;
            sumo = c1 * 2 + c2 + c3;
            sumc = c4 * 2 + c2 + c3;
            if (sumo == sumc)
                Console.WriteLine("1");
            else
                Console.WriteLine("0");
        }
    }
}

using System;
using System.Collections.Generic;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1 = Convert.ToInt32(Console.ReadLine());//((
            int c2 = Convert.ToInt32(Console.ReadLine());//()
            int c3 = Convert.ToInt32(Console.ReadLine());//)(
            int c4 = Convert.ToInt32(Console.ReadLine());//))

            int sumo1 = c1 * 2;
            int sumo3 = c3;
            int sumo4 = c4 * 2;

            if (sumo1==sumo4&&sumo3<=sumo1) {
                Console.WriteLine("1");

            }
            else
                Console.WriteLine("0");
        }
    }
}

using System;
using System.Collections.Generic;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1 = Convert.ToInt32(Console.ReadLine());//((
            int c2 = Convert.ToInt32(Console.ReadLine());//()
            int c3 = Convert.ToInt32(Console.ReadLine());//)(
            int c4 = Convert.ToInt32(Console.ReadLine());//))

            int sumo1 = c1 * 2;
            int sumo3 = c3;
            int sumo4 = c4 * 2;

            if (sumo1==sumo4&&sumo3<=sumo1|| sumo1 == sumo4 && sumo3 >=1) {
                Console.WriteLine("1");

            }
            else
                Console.WriteLine("0");
        }
    }
}

using System;
using System.Collections.Generic;

namespace ConsoleApp11
{
    class Program
    {
        static void Main(string[] args)
        {
            int c1 = Convert.ToInt32(Console.ReadLine());//((
            int c2 = Convert.ToInt32(Console.ReadLine());//()
            int c3 = Convert.ToInt32(Console.ReadLine());//)(
            int c4 = Convert.ToInt32(Console.ReadLine());//))

            string str1 = new string ('(', c1*2);
            string str2 = "";// new string ("()", c2);
            string str3 = ""; //new string (")(", c3);
            string str4 = new string (')', c4);

            for (int i = 0; i < c2; i++)
            {
                str2 += "()";

            }

            for (int i = 0; i < c3; i++)
            {
                str3 += ")(";

            }

            int sumo = 0;

            int sum = 0;

            string strcom = str1 + str2 + str3 + str4;
            foreach (char n in strcom) {
                if (n == '(')
                {
                    sumo = sumo + 1;
                }
                else if (n == ')' && sumo > 0)
                {
                    sum = sum + 1;
                    sumo = sumo - 1;
                }
            }

            if (strcom.Length == sum * 2) {
                Console.WriteLine("1");

            }
            else
                Console.WriteLine("0");
        }
    }
}


Nastya received a gift on New Year — a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month).Unfortunately, right after the doubling the wardrobe eats one of the dresses (if any) with the 50% probability. It happens every month except the last one in the year. Nastya owns x dresses now, so she became interested in the expected number of dresses she will have in one year. Nastya lives in Byteland, so the year lasts for k + 1 months.Nastya is really busy, so she wants you to solve this problem. You are the programmer, after all. Also, you should find the answer modulo 109 + 7, because it is easy to see that it is always integer.

The only line contains two integers x and k (0 ≤ x, k ≤ 1018), where x is the initial number of dresses and k + 1 is the number of months in a year in Byteland.

In the only line print a single integer — the expected number of dresses Nastya will own one year later modulo 109 + 7.

NoteIn the first example a year consists on only one month, so the wardrobe does not eat dresses at all.In the second example after the first month there are 3 dresses with 50% probability and 4 dresses with 50% probability. Thus, in the end of the year there are 6 dresses with 50% probability and 8 dresses with 50% probability. This way the answer for this test is (6 + 8) / 2 = 7.

using System;
using System.IO;
using System.Numerics;
using System.Collections.Generic;

namespace Z5
{
	class Program
	{
		static BigInteger MOD = 1000 * 1000 * 1000 + 7;
		static BigInteger BinPow(BigInteger p)
		{
			BigInteger res = 1;
			BigInteger num = 2;

			while (p > 0)
			{
				if(p % 2 == 1)
				{
					res *= num;
					res %= MOD;
					--p;
				}
				else
				{
					num *= num;
					num %= MOD;
					p /= 2;
				}
			}

			return res;
		}

		static void Main(string[] args)
		{
			string[] req = Console.ReadLine().Split(' ');

			BigInteger n, k;

			long t;
			t = long.Parse(req[0]);
			n = t;

			t = long.Parse(req[1]);
			k = t;

			if(n==0)
			{
				Console.WriteLine(0);
				return;
			}

			BigInteger p = BinPow(k);

			BigInteger res = 2 * p * n - p + 1;
			Console.WriteLine(res % MOD);
		}
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;

class Solver
{
    Scanner sc = new Scanner();
    //

    public void Solve()
    {
        var a = sc.Next<long>();
        ModInt x = a; long k = sc.Next<long>();
        if (a == 0) Fail(0);
        if (k == 0) Fail((x << 1) % ModInt.MOD);
        WriteLine(ModInt.Pow(2, k) * (2 * x - 1) + 1);
    }
}

public struct ModInt
{
    public const long MOD = (int)1e9 + 7;
    //public const long MOD = 998244353;
    public long Value { get; set; }
    public ModInt(long n = 0) { Value = n; }
    private static ModInt[] fac;//階乗
    private static ModInt[] inv;//逆数
    private static ModInt[] facinv;//1/(i!)
    public override string ToString() => Value.ToString();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Value += r.Value;
        if (l.Value >= MOD) l.Value -= MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Value -= r.Value;
        if (l.Value < 0) l.Value += MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt l) => l.Value;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long n)
    {
        n %= MOD; if (n < 0) n += MOD;
        return new ModInt(n);
    }

    public static ModInt Pow(ModInt m, long n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(m * m, n >> 1);
        else return Pow(m * m, n >> 1) * m;
    }

    public static void Build(int n)
    {
        fac = new ModInt[n + 1];
        facinv = new ModInt[n + 1];
        inv = new ModInt[n + 1];
        inv[1] = 1;
        fac[0] = fac[1] = 1;
        facinv[0] = facinv[1] = 1;
        for (var i = 2; i <= n; i++)
        {
            fac[i] = fac[i - 1] * i;
            inv[i] = MOD - inv[MOD % i] * (MOD / i);
            facinv[i] = facinv[i - 1] * inv[i];
        }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Fac(ModInt n) => fac[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Inv(ModInt n) => inv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt FacInv(ModInt n) => facinv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Comb(ModInt n, ModInt r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        var calc = fac[n];
        calc = calc * facinv[r];
        calc = calc * facinv[n - r];
        return calc;
    }
}
#region Template
public class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b)
    { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f();
        return rt;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<int, T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f(i);
        return rt;
    }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}

public class Scanner
{
    public string Str => ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    public Pair<T1, T2> PairMake<T1, T2>() => new Pair<T1, T2>(Next<T1>(), Next<T2>());
    public Pair<T1, T2, T3> PairMake<T1, T2, T3>() => new Pair<T1, T2, T3>(Next<T1>(), Next<T2>(), Next<T3>());
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
}

public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Tie(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Tie(out T1 a, out T2 b, out T3 c) { Tie(out a, out b); c = v3; }
}
#endregion

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

namespace Nastya_and_a_Wardrobe
{
    internal class Program
    {
        private const int mod = 1000000007;
        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)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static long Pow(long a, long k)
        {
            long r = 1;
            while (k > 0)
            {
                if ((k & 1) == 1)
                {
                    r = (r*a)%mod;
                }
                a = (a*a)%mod;
                k >>= 1;
            }
            return r;
        }

        private static long Solve(string[] args)
        {
            long x = Next();
            long k = Next();

            if (x == 0)
                return 0;

            long p = Pow(2, k);
            long ans = ((p * 2 + 2) / 2 + 2 * ((x - 1) % mod) * (p % mod)) % mod;
            return ans;
        }

        private static long Next()
        {
            int c;
            long 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';
            }
        }
    }
}

#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

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

#if DEBUG
using System.Diagnostics;
#endif

namespace _489с
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;
        const string _delim = "!";

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
            var testNumber = 0;
            var timer = new Stopwatch();
            foreach (var test in GetTests())
            {

                timer.Start();

                var defaultColor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine($"<!-- TEST #{testNumber} -->");
                Console.ForegroundColor = defaultColor;
                Console.SetIn(test);

#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
#if DEBUG
                Solution(testNumber);
#else
                Solution(0);
#endif
            }
            finally
            {
#if DEBUG
#else
                if (_useFileInput)
                {
                    file.Close();
                }
#endif
            }

#if DEBUG
                timer.Stop();

                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine($"<!-- TEST #{testNumber} FINISHED IN {timer.Elapsed.ToString(@"ss\:fff")}-->");
                Console.ForegroundColor = defaultColor;

                timer.Reset();
                testNumber++;
            }
#endif
        }

        static long mod = 1000 * 1000 * 1000 + 7;

        static void Solution(int testNumber)
        {
            checked
            {
                #region SOLUTION
                var d = ReadLongArray();
                var x = d[0];
                var k = d[1];

                if (x == 0)
                {
                    Console.WriteLine(0);
                    return;
                }

                x %= mod;
                k++;
                var kp = Pow(2, k);
                kp *= x;
                kp %= mod;

                var next = 1L;
                if (k == 2)
                {
                    next = -1;
                }
                else if (k == 1)
                {
                    next = 0;
                }
                else if (k > 2)
                {
                    //var gp = (1 - Pow(2, k - 2)) / (1 - 2);
                    next = -Pow(2, k - 1) + 1;
                    next %= mod;
                }

                var res = kp + next;
                if (res < 0)
                {
                    res += mod;
                }
                res %= mod;

                Console.WriteLine(res);
            }
            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

        static long Pow(long a, long pp)
        {
            checked
            {
                var res = 1L;
                while (true)
                {
                    if (pp % 2 == 1)
                    {
                        res *= a;
                        res %= mod;
                        pp--;
                    }
                    else
                    {
                        pp /= 2;
                        a *= a;

                        a %= mod;
                    }

                    if (pp == 0)
                    {
                        break;
                    }
                }

                return res;
            }

        }

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

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

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
        static IEnumerable<TextReader> GetTests()
        {
            var tests = new List<string>();
            var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
            using (var resource = new StreamReader(Assembly.GetCallingAssembly().GetManifestResourceStream(resName)))
            {
                while (true)
                {
                    var nextText = new StringBuilder();
                    var endOfFile = false;
                    while (true)
                    {
                        var line = resource.ReadLine();

                        endOfFile = line == null;
                        if (endOfFile)
                        {
                            break;
                        }

                        if (line.StartsWith(_delim, StringComparison.Ordinal))
                        {
                            break;
                        }

                        nextText.AppendLine(line);
                    }

                    yield return new StringReader(nextText.ToString());

                    if (endOfFile)
                    {
                        break;
                    }
                }
            }
        }
#endif
    }
}

using System;
using System.Globalization;
using System.Threading;

public static class ProblemC
{
    #region Common routines

    private static int _currentTokenNumber;

    private static string[] _tokens;

    private static void StartReading()
    {
        _currentTokenNumber = 0;

        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

        _tokens = Console.In.ReadToEnd().Split(new[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
    }

    private static string NextString()
    {
        return _tokens[_currentTokenNumber++];
    }

    private static int NextInt()
    {
        return int.Parse(NextString());
    }

    private static long NextLong()
    {
        return long.Parse(NextString());
    }

    #endregion

    private const long Mod = 1000000007;

    private static void Main(string[] args)
    {
        StartReading();

        long x = NextLong();
        long k = NextLong();

        var result = Solve(x, k);

        Console.WriteLine(result);
    }

    private static long Solve(long x, long k)
    {
        if (x == 0) return 0;
        x = (x * 2)%Mod;

        long d = Deg2(k);

        long result = (x * d) % Mod - d + 1;
        while (result < 0) result += Mod;
        return result;

    }

    private static long Deg2(long n)
    {
        if (n == 0) return 1;
        var mid = Deg2(n / 2);

        long result = (mid * mid) % Mod;
        if (n % 2 == 1) result = (result * 2) % Mod;
        return result;
    }
}

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

namespace bla
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            long x = long.Parse(s[0]);
            long k = long.Parse(s[1]) + 1;
            if (x == 0)
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine((((((x % mod) * pow(k)) % mod) - pow(k - 1) + 1) % mod + mod) % mod);
            }
        }

        static long mod = 1000000007;

        static long pow(long n) //2^n
        {
            if (n == 0)
                return 1;
            if(n % 2 == 0)
            {
                long a = pow(n / 2);
                return (a * a) % mod;
            }
            return (2 * pow(n - 1)) % mod;
        }
    }
}

using System;
using System.IO;
using System.Numerics;
using System.Collections.Generic;

namespace Z5
{
	class Program
	{
		static BigInteger MOD = 1000 * 1000 * 1000 + 7;
		static BigInteger BinPow(BigInteger p)
		{
			BigInteger res = 1;
			BigInteger num = 2;

			while (p > 0)
			{
				if(p % 2 == 1)
				{
					res *= num;
					res %= MOD;
					--p;
				}
				else
				{
					num *= num;
					num %= MOD;
					p /= 2;
				}
			}

			return res;
		}

		static void Main(string[] args)
		{
			string[] req = Console.ReadLine().Split(' ');

			BigInteger n, k;

			long t;
			t = long.Parse(req[0]);
			n = t;

			t = long.Parse(req[1]);
			k = t;

			BigInteger p = BinPow(k);

			BigInteger res = 2 * p * n - p + 1;
			Console.WriteLine(res % MOD);
		}
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using static Template;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pi = Pair<int, int>;

class Solver
{
    Scanner sc = new Scanner();
    //

    public void Solve()
    {
        long x, k;
        sc.Make(out x, out k);
        x %= ModInt.MOD;
        if (x == 0) Fail(0);
        if (k == 0) Fail((x << 1) % ModInt.MOD);
        WriteLine(ModInt.Pow(2, k ) * (2*x - 1) + 1);
    }
}

public struct ModInt
{
    public const long MOD = (int)1e9 + 7;
    //public const long MOD = 998244353;
    public long Value { get; set; }
    public ModInt(long n = 0) { Value = n; }
    private static ModInt[] fac;//階乗
    private static ModInt[] inv;//逆数
    private static ModInt[] facinv;//1/(i!)
    public override string ToString() => Value.ToString();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt l, ModInt r)
    {
        l.Value += r.Value;
        if (l.Value >= MOD) l.Value -= MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt l, ModInt r)
    {
        l.Value -= r.Value;
        if (l.Value < 0) l.Value += MOD;
        return l;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator *(ModInt l, ModInt r) => new ModInt(l.Value * r.Value % MOD);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt l, ModInt r) => l * Pow(r, MOD - 2);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt l) => l.Value;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long n)
    {
        n %= MOD; if (n < 0) n += MOD;
        return new ModInt(n);
    }

    public static ModInt Pow(ModInt m, long n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(m * m, n >> 1);
        else return Pow(m * m, n >> 1) * m;
    }

    public static void Build(int n)
    {
        fac = new ModInt[n + 1];
        facinv = new ModInt[n + 1];
        inv = new ModInt[n + 1];
        inv[1] = 1;
        fac[0] = fac[1] = 1;
        facinv[0] = facinv[1] = 1;
        for (var i = 2; i <= n; i++)
        {
            fac[i] = fac[i - 1] * i;
            inv[i] = MOD - inv[MOD % i] * (MOD / i);
            facinv[i] = facinv[i - 1] * inv[i];
        }
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Fac(ModInt n) => fac[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Inv(ModInt n) => inv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt FacInv(ModInt n) => facinv[n];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt Comb(ModInt n, ModInt r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        var calc = fac[n];
        calc = calc * facinv[r];
        calc = calc * facinv[n - r];
        return calc;
    }
}
#region Template
public class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve();
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == 1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T>
    { if (a.CompareTo(b) == -1) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b)
    { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f();
        return rt;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static T[] Create<T>(int n, Func<int, T> f)
    {
        var rt = new T[n];
        for (var i = 0; i < rt.Length; ++i)
            rt[i] = f(i);
        return rt;
    }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}

public class Scanner
{
    public string Str => ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    public Pair<T1, T2> PairMake<T1, T2>() => new Pair<T1, T2>(Next<T1>(), Next<T2>());
    public Pair<T1, T2, T3> PairMake<T1, T2, T3>() => new Pair<T1, T2, T3>(Next<T1>(), Next<T2>(), Next<T3>());
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
}

public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Tie(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Tie(out T1 a, out T2 b, out T3 c) { Tie(out a, out b); c = v3; }
}
#endregion

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

namespace Nastya_and_a_Wardrobe
{
    internal class Program
    {
        private const int mod = 1000000007;
        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)
        {
            writer.WriteLine(Solve(args));
            writer.Flush();
        }

        private static long Pow(long a, long k)
        {
            long r = 1;
            while (k > 0)
            {
                if ((k & 1) == 1)
                {
                    r = (r*a)%mod;
                }
                a = (a*a)%mod;
                k >>= 1;
            }
            return r;
        }

        private static long Solve(string[] args)
        {
            long x = Next();
            long k = Next();

            if (x == 0)
                return 0;

            long p = Pow(2, k);
            long ans = ((p*2 + 2)/2 + 2*(x - 1)*p)%mod;
            return ans;
        }

        private static long Next()
        {
            int c;
            long 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';
            }
        }
    }
}

#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

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

#if DEBUG
using System.Diagnostics;
#endif

namespace _489с
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;
        const string _delim = "!";

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
            var testNumber = 0;
            var timer = new Stopwatch();
            foreach (var test in GetTests())
            {

                timer.Start();

                var defaultColor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine($"<!-- TEST #{testNumber} -->");
                Console.ForegroundColor = defaultColor;
                Console.SetIn(test);

#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
#if DEBUG
                Solution(testNumber);
#else
                Solution(0);
#endif
            }
            finally
            {
#if DEBUG
#else
                if (_useFileInput)
                {
                    file.Close();
                }
#endif
            }

#if DEBUG
                timer.Stop();

                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine($"<!-- TEST #{testNumber} FINISHED IN {timer.Elapsed.ToString(@"ss\:fff")}-->");
                Console.ForegroundColor = defaultColor;

                timer.Reset();
                testNumber++;
            }
#endif
        }

        static long mod = 1000 * 1000 * 1000 + 7;

        static void Solution(int testNumber)
        {
            #region SOLUTION
            var d = ReadLongArray();
            var x = d[0];
            var k = d[1];

            if (x == 0)
            {
                Console.WriteLine(0);
                return;
            }

            k++;
            var kp = Pow(2, k);
            kp *= x;
            kp %= mod;

            var next = 1L;
            if (k == 2)
            {
                next = -1;
            }
            else if (k == 1)
            {
                next = 0;
            }
            else if (k > 2)
            {
                next = -Pow(2, k - 2) - 1;
            }

            var res = kp + next;
            res %= mod;

            Console.WriteLine(res);
            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

        static long Pow(long a, long pp)
        {
            var res = 1L;
            while (true)
            {
                if (pp % 2 == 1)
                {
                    res *= a;
                    res %= mod;
                    pp--;
                }
                else
                {
                    pp /= 2;
                    a *= a;

                    a %= mod;
                }

                if (pp == 0)
                {
                    break;
                }
            }

            return res;
        }

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

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

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
        static IEnumerable<TextReader> GetTests()
        {
            var tests = new List<string>();
            var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
            using (var resource = new StreamReader(Assembly.GetCallingAssembly().GetManifestResourceStream(resName)))
            {
                while (true)
                {
                    var nextText = new StringBuilder();
                    var endOfFile = false;
                    while (true)
                    {
                        var line = resource.ReadLine();

                        endOfFile = line == null;
                        if (endOfFile)
                        {
                            break;
                        }

                        if (line.Equals(_delim, StringComparison.Ordinal))
                        {
                            break;
                        }

                        nextText.AppendLine(line);
                    }

                    yield return new StringReader(nextText.ToString());

                    if (endOfFile)
                    {
                        break;
                    }
                }
            }
        }
#endif
    }
}

#if DEBUG
using System.Reflection;
using System.Threading.Tasks;
#endif

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

#if DEBUG
using System.Diagnostics;
#endif

namespace _489с
{
    class Program
    {
        static string _inputFilename = "input.txt";
        static string _outputFilename = "output.txt";
        static bool _useFileInput = false;
        const string _delim = "!";

        static void Main(string[] args)
        {
            StreamWriter file = null;
#if DEBUG
            var testNumber = 0;
            var timer = new Stopwatch();
            foreach (var test in GetTests())
            {

                timer.Start();

                var defaultColor = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine($"<!-- TEST #{testNumber} -->");
                Console.ForegroundColor = defaultColor;
                Console.SetIn(test);

#else
            if (_useFileInput)
            {
                Console.SetIn(File.OpenText(_inputFilename));
                file = new StreamWriter(_outputFilename);
                Console.SetOut(file);
            }
#endif

            try
            {
#if DEBUG
                Solution(testNumber);
#else
                Solution(0);
#endif
            }
            finally
            {
#if DEBUG
#else
                if (_useFileInput)
                {
                    file.Close();
                }
#endif
            }

#if DEBUG
                timer.Stop();

                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine($"<!-- TEST #{testNumber} FINISHED IN {timer.Elapsed.ToString(@"ss\:fff")}-->");
                Console.ForegroundColor = defaultColor;

                timer.Reset();
                testNumber++;
            }
#endif
        }

        static long mod = 1000 * 1000 * 1000 + 7;

        static void Solution(int testNumber)
        {
            #region SOLUTION
            var d = ReadLongArray();
            var x = d[0];
            var k = d[1];

            if (x == 0)
            {
                Console.WriteLine(0);
                return;
            }

            k++;
            var kp = Pow(2, k);
            kp *= x;
            kp %= mod;

            var next = 1L;
            if (k == 2)
            {
                next = -1;
            }
            else if (k == 1)
            {
                next = 0;
            }
            else if (k > 2)
            {
                //var gp = (1 - Pow(2, k - 2)) / (1 - 2);
                next = -Pow(2, k - 1) + 1;
            }

            var res = kp + next;
            res %= mod;

            Console.WriteLine(res);
            //var n = readInt();
            //var m = readInt();

            //var a = readIntArray();
            //var b = readIntArray();
            #endregion
        }

        static long Pow(long a, long pp)
        {
            var res = 1L;
            while (true)
            {
                if (pp % 2 == 1)
                {
                    res *= a;
                    res %= mod;
                    pp--;
                }
                else
                {
                    pp /= 2;
                    a *= a;

                    a %= mod;
                }

                if (pp == 0)
                {
                    break;
                }
            }

            return res;
        }

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

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

        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => int.Parse(i)).ToArray();
        }

        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Where(i => !string.IsNullOrEmpty(i)).Select(i => long.Parse(i)).ToArray();
        }

#if DEBUG
        static IEnumerable<TextReader> GetTests()
        {
            var tests = new List<string>();
            var resName = Assembly.GetCallingAssembly().GetManifestResourceNames()[0];
            using (var resource = new StreamReader(Assembly.GetCallingAssembly().GetManifestResourceStream(resName)))
            {
                while (true)
                {
                    var nextText = new StringBuilder();
                    var endOfFile = false;
                    while (true)
                    {
                        var line = resource.ReadLine();

                        endOfFile = line == null;
                        if (endOfFile)
                        {
                            break;
                        }

                        if (line.StartsWith(_delim, StringComparison.Ordinal))
                        {
                            break;
                        }

                        nextText.AppendLine(line);
                    }

                    yield return new StringReader(nextText.ToString());

                    if (endOfFile)
                    {
                        break;
                    }
                }
            }
        }
#endif
    }
}

using System;
using System.Globalization;
using System.Threading;

public static class ProblemC
{
    #region Common routines

    private static int _currentTokenNumber;

    private static string[] _tokens;

    private static void StartReading()
    {
        _currentTokenNumber = 0;

        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

        _tokens = Console.In.ReadToEnd().Split(new[] { ' ', '\t', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
    }

    private static string NextString()
    {
        return _tokens[_currentTokenNumber++];
    }

    private static int NextInt()
    {
        return int.Parse(NextString());
    }

    private static long NextLong()
    {
        return long.Parse(NextString());
    }

    #endregion

    private const long Mod = 1000000007;

    private static void Main(string[] args)
    {
        StartReading();

        long x = NextLong();
        long k = NextLong();

        var result = Solve(x, k);

        Console.WriteLine(result);
    }

    private static long Solve(long x, long k)
    {
        if (x == 0) return 0;
        x = x * 2;

 long d = Deg2(k);

        long result = (x * d) % Mod - d + 1;
        while (result < 0) result += Mod;
        return result;

    }

    private static long Deg2(long n)
    {
        if (n == 0) return 1;
        var mid = Deg2(n / 2);

        long result = (mid * mid) % Mod;
        if (n % 2 == 1) result = (result * 2) % Mod;
        return result;
    }
}