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 10^9 + 7, because it is easy to see that it is always integer.


-----Input-----

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


-----Output-----

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


-----Examples-----
Input
2 0

Output
4

Input
2 1

Output
7

Input
3 2

Output
21



-----Note-----

In 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.

Difficulty: MEDIUM_HARD
Tags: Mathematics
Expected Time Complexity: O(Log(N))

Starter code:

Solutions:
mod = 1000000007
(x, k) = map(int, input().split())
if x == 0:
	print(0)
else:
	ans = (pow(2, k + 1, mod) * x % mod - (pow(2, k, mod) - 1 + mod) % mod + mod) % mod
	print(ans)


(n, k) = [int(x) for x in input().split()]
if n == 0:
	print(0)
	exit()
p = int(1000000000.0 + 7)
n %= p
print((n * pow(2, k + 1, p) - (pow(2, k, p) - 1)) % p)


(x, k) = map(int, input().split())
mo = 1000000007
if not x:
	print(0)
elif not k:
	print(x * 2 % mo)
else:
	ans = x * pow(2, k + 1, mo) + 1 - pow(2, k, mo)
	ans %= mo
	ans += mo
	ans %= mo
	print(ans)


from sys import stdin
(x, k) = map(int, stdin.readline().split())
if x == 0:
	print(0)
else:
	mod = 1000000007
	a = pow(2, k, mod) % mod
	b = 2 * a % mod
	print((x % mod * (b % mod) % mod - a % mod + 1 + mod) % mod)


(x, k) = [int(i) for i in input().split()]
if x == 0:
	p = 0
else:
	s = 10 ** 9 + 7
	a = pow(2, k, s)
	p = a * (2 * x - 1)
	p = (p + 1) % s
print(p)


mod = 1000000000 + 7
(n, m) = map(int, input().split())
if n == 0:
	print(0)
	exit()
ans = n * 2
ans %= mod
if m:
	t = 1
	x = 2
	while m > 0:
		if m & 1:
			t = t * x % mod
		x = x * x % mod
		m >>= 1
	ans -= 1
	ans = (t * ans + 1) % mod
print(ans)


modulo = 10 ** 9 + 7
(x, k) = [int(s) for s in input().split()]
if x == 0:
	print(0)
	exit(0)
k2 = pow(2, k, modulo)
ans = (x * k2 * 2 - k2 + 1) % modulo
print(ans)


(x, k) = map(int, input().split())
rem = 1000000007
if x == 0:
	print(0)
else:
	print((pow(2, k + 1, rem) * (x % rem) % rem - (pow(2, k, rem) - 1 % rem) % rem) % rem)


def my_pow(a, n, m):
	if n == 0:
		return 1
	ans = my_pow(a, n // 2, m)
	if n % 2 == 0:
		return ans * ans % m
	else:
		return ans * ans * a % m
(x, k) = map(int, input().split())
if x == 0:
	print(0)
else:
	mod = 10 ** 9 + 7
	x *= 2
	ans = (x - 1) * my_pow(2, k, mod) + 1
	ans %= mod
	ans += 2 * mod
	print(ans % mod)


n = [int(x) for x in input().split(' ')]
M = 1000000007

def a(k):
	M = 1000000007
	if k > 0:
		l = a(k // 2)
		return l * l * (k % 2 + 1) % M
	else:
		return 1
if n[0] == 0:
	print(0)
else:
	l = a(n[1])
	print((2 * (n[0] % M) * l - l + 1) % M)


import sys

def powmod(a, p, m):
	res = 1
	while p > 0:
		if p & 1:
			res = res * a % m
		a = a * a % m
		p //= 2
	return res
(x, k) = map(int, input().split())
Mod = 10 ** 9 + 7
if x == 0:
	print(0)
else:
	t = (2 * x - 1) * powmod(2, k + 1, Mod) + 2
	if t & 1:
		t += Mod
	print(t // 2 % Mod)


(x, k) = map(int, input().split(' '))
M = 10 ** 9 + 7

def get(x, k):
	if k == 0:
		return x
	else:
		a = pow(2, k - 1, M)
		b = (2 * x - 1) * pow(2, k, M) + 1
		c = pow(pow(2, k, M), M - 2, M)
		ans = a * b * c % M
		return ans
if k == 0 or x == 0:
	print(x * 2 % M)
else:
	ans = get(x, k) * 2 % M
	print(ans)


def read():
	return [int(v) for v in input().split()]

def main():
	mod = 10 ** 9 + 7
	(x, k) = read()
	if x == 0:
		print(0)
	else:
		print((pow(2, k, mod) * (2 * x - 1) + 1) % mod)
main()


l = input().split(' ')
x = int(l[0])
k = int(l[1])
if x == 0:
	print('0')
else:
	mod = 1000000007

	def pow_mod(a, b):
		if b < 2:
			return int(a ** b) % mod
		elif b % 2 == 0:
			return int(pow_mod(a, b // 2) ** 2) % mod
		else:
			return pow_mod(a, b - 1) * a % mod
	twop = pow_mod(2, k)
	high = x * twop
	leafs = twop
	low = high - leafs + 1
	s = (high + 1) * high // 2 - (low - 1 + 1) * (low - 1) // 2
	answer = s * 2 // leafs
	answer %= mod
	print(answer)


(x, k) = map(int, input().split())
mod = 1000 * 1000 * 1000 + 7
if x == 0:
	print(0)
else:
	mul = pow(2, k + 1, mod)
	cnt = pow(2, k, mod)
	s1 = mul * cnt * x
	s2 = cnt * (cnt - 1)
	ans = (s1 - s2) % mod
	rev = pow(cnt, mod - 2, mod)
	assert rev * cnt % mod == 1
	ans *= rev
	print(ans % mod)


(a, b) = input().split()
x = int(a)
k = int(b)
mod = 10 ** 9 + 7
if x == 0:
	print(0)
elif k == 0:
	print(2 * x % mod)
else:
	print(((pow(2, k, mod) * x - pow(2, k - 1, mod)) % mod * 2 + 3 * mod + 1) % mod)


mod = 10 ** 9 + 7
(x, k) = map(int, input().split())
if x != 0:
	print((pow(2, k + 1, mod) * x - pow(2, k, mod) + 1) % mod)
else:
	print(0)


config = input().split()
tran = lambda n, t: pow(2, t, 1000000007) * (2 * n - 1) + 1
if config[0] != '0':
	print(tran(int(config[0]), int(config[1])) % 1000000007)
else:
	print(0)


(n, k) = map(int, input().split(' '))
arr = [n]
k = k + 1
z = 1000000007
c = (n * pow(2, k, z) - pow(2, k - 1, z) + 1) % z
if n == 0:
	print(0)
else:
	print(c)


m = 1000000007

def power(x, y, p=1000000007):
	res = 1
	x = x % p
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
(x, k) = list(map(int, input().split()))
if x == 0:
	print(0)
elif k == 0:
	print(x * 2 % m)
else:
	temp = power(2, k)
	maxi = x * temp % m * 2 % m
	mini = (m + maxi - 2 * (temp - 1) % m) % m
	print((maxi + mini) % m * 500000004 % m)


MOD = 10 ** 9 + 7
(x, k) = map(int, input().split())
y = (2 * x - 1) % MOD
mult = pow(2, k, MOD)
if x:
	print((y * mult + 1) % MOD)
else:
	print(0)


mod = 10 ** 9 + 7
(x, k) = [int(x) for x in input().split()]
if x == 0:
	print(0)
else:
	T = [1]
	for j in range(1024):
		T.append(2 * T[-1] % mod)
	L = [1]
	for i in range(10 ** 6):
		L.append(T[1024] * L[-1] % mod)
	k = k % (mod - 1)
	t1 = k % 1024
	t2 = (k + 1) % 1024
	q1 = k // 1024
	q2 = (k + 1) // 1024
	A = L[q2] * T[t2] % mod
	A *= x
	A = A % mod
	B = L[q1] * T[t1] % mod
	print((A - B + 1) % mod)


MOD = int(1000000000.0 + 7)
(x, k) = map(int, input().split())
if x == 0:
	print(0)
else:
	print((x * pow(2, k + 1, MOD) - pow(2, k, MOD) + 1) % MOD)


(x, k) = map(int, input().strip().split())
MOD = 1000000007
if x > 0:
	r = (pow(2, k + 1, MOD) * x - pow(2, k, MOD) + 1 + MOD * 10) % MOD
else:
	r = 0
print(r)


import math
mod = 10 ** 9 + 7

def calcpower(num, power, mod):
	if power == 0:
		return 1
	a = [num]
	temp = num
	for i in range(int(math.log(power, 2))):
		temp *= temp
		temp = temp % mod
		a.append(temp % mod)
	power = bin(power)[2:]
	power = power[::-1]
	res = 1
	for i in range(len(power)):
		if int(power[i]):
			res = res * a[i] % mod
	return res % mod
import sys
(x, k) = map(int, input().split())
if x == 0:
	print(0)
	sys.exit()
if k == 0:
	print(2 * x % mod)
	sys.exit()
ans = (2 * x - 1) * calcpower(2, k, mod) + 1
print(ans % mod)


(x, k) = map(int, input().split())
md = 10 ** 9 + 7
res = x * pow(2, k + 1, md) - pow(2, k, md) + 1 if x > 0 else 0
print(res % md)


import sys

def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
mod = 10 ** 9 + 7
(r, k) = map(int, input().split())
if r == 0:
	print(0)
	sys.exit()
print((power(2, k + 1, mod) % mod * (r % mod) % mod - power(2, k, mod) + 1) % mod)


(x, k) = map(int, input().split())
if x == 0:
	print(0)
	exit()
mod = 10 ** 9 + 7
ans = 1 + (2 * x - 1) * pow(2, k, mod)
print(ans % mod)


def pw(y):
	if y == 0:
		return 1
	z = pw(y // 2)
	z = z * z % 1000000007
	if y % 2 != 0:
		z = z * 2 % 1000000007
	return z
(n, k) = map(int, input().split())
x = n * 2 - 1
if n == 0:
	print(0)
else:
	mod = 1000000007
	print((x * pw(k) + 1) % mod)


(x, k) = map(int, input().split())
MOD = 1000000007
pw = pow(2, k + 1, MOD)
n = pow(2, k, MOD)
a = pw * x - n
a = (a + 1) % MOD
if x == 0:
	a = 0
print(int(a))


def f(k):
	res = 1
	a = 2
	while k:
		if k % 2 == 1:
			res *= a
			k -= 1
		else:
			a *= a
			k //= 2
		res = res % 1000000007
		a = a % 1000000007
	return res
(n, k) = map(int, input().split())
if n == 0:
	print(0)
elif k == 0:
	print(n * 2 % 1000000007)
else:
	first = (2 * n - 1) % 1000000007
	first *= f(k)
	first = (first + 1) % 1000000007
	print(first)


import os
import sys
import math
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(x, k) = map(int, input().split())
res = 0
mod = 1000000007
res = pow(2, k, mod) * (2 * x - 1) + 1
res %= mod
if x == 0:
	res = 0
print(res)


MOD = 10 ** 9 + 7
(x, k) = map(int, input().split())
if not x:
	print(0)
else:
	two_power_k = pow(2, k, MOD)
	answer = two_power_k * 2 * x - two_power_k + 1
	print(answer % MOD)


def mul(x, y, md):
	return x * y % md

def power(x, y, md):
	res = 1
	while y != 0:
		if y & 1:
			res = mul(res, x, 1000000007)
		x = mul(x, x, 1000000007)
		y >>= 1
	return res

def inv(x, md):
	return power(x, md - 2, 1000000007)
t = input().split()
a = int(t[0])
k = int(t[1])
if a == 0:
	print(0)
else:
	first = power(2, 2 * k, 1000000007)
	second = power(2, k, 1000000007)
	ans = mul(first, 2 * a - 1, 1000000007) + second
	third = inv(second, 1000000007)
	ans = mul(ans, third, 1000000007)
	print(ans)


mod = 1000000000 + 7

def fp(x, y):
	if y == 1:
		return x
	if y == 0:
		return 1
	t = fp(x, y // 2) % mod
	if y % 2 == 1:
		return t * t * x
	else:
		return t * t

def inv(x):
	return fp(x % mod, mod - 2) % mod
(n, k) = list(map(int, input().split()))
if not n:
	print(0)
	exit()
if not k:
	print(2 * n % mod)
	exit()
numberOfPro = fp(2, k)
last = n * numberOfPro
first = (n - 1) * numberOfPro + 1
sumOfLast = last * (last + 1) * inv(2)
sumOfFirst = first * (first - 1) * inv(2)
num = 2 * (sumOfLast - sumOfFirst) * inv(numberOfPro)
print(num % mod)


from copy import deepcopy
(x, k) = map(int, input().split(' '))
if x == 0:
	print(0)
else:
	print((pow(2, k, 1000000007) * ((2 * x - 1) % 1000000007) + 1) % 1000000007)


(x, n) = map(int, input().split())
MOD = 10 ** 9 + 7
c = 4 * x
if c == 0:
	ans = 0
elif n == 0:
	ans = 2 * x
else:
	ans = ((c - 2) * pow(2, n - 1, MOD) + 1 + MOD) % MOD
print(ans % MOD)


def main():
	(x, k) = list(map(int, input().split()))
	if x == 0:
		print(0)
		return 0

	def helper(n):
		if n == 0:
			return 1
		p = 1
		ret = 2
		while n >= 2 * p:
			p *= 2
			ret = ret ** 2 % 1000000007
		return ret * helper(n - p)
	x = x % 1000000007
	k = k % 1000000006
	a = helper(k)
	print((2 * a * x - a + 1) % 1000000007)
	return 0
main()


x = input()
(x, k) = x.split()
x = int(x)
k = int(k)
mul = pow(2, k + 1, 1000000007)
y = x % 1000000007 * mul % 1000000007
ans = y
if x != 0:
	ans = (ans % 1000000007 - (pow(2, k, 1000000007) - 1) % 1000000007) % 1000000007
print(ans)


(x, k) = [int(i) for i in input().split()]
if x == 0:
	print(0)
	exit()
p = int(10 ** 9 + 7)
x %= p
print((x * pow(2, k + 1, p) - (pow(2, k, p) - 1)) % p)


(x, k) = list(map(int, input().split()))
md = 1000000007
print((pow(2, k + 1, md) * x - pow(2, k, md) + 1) % md if x > 0 else 0)


(x, k) = map(int, input().split())
m = 1000000007
if x == 0:
	print(0)
elif x != 0:
	print((pow(2, k + 1, m) * x - pow(2, k, m) + 1) % m)


from sys import stdin
line = stdin.readline().rstrip().split()
x = int(line[0])
k = int(line[1])
if x == 0:
	print(0)
else:
	nn = pow(2, k, 1000000007)
	result = (nn * 2 * x - nn + 1) % 1000000007
	print(result)


(x, k) = map(int, input().split())
if x == 0:
	print(0)
else:
	y = pow(2, k, 1000000007) * (2 * x - 1) + 1
	result = int(y % 1000000007)
	print(result)


import sys, math
debug = 0
if debug:
	f = open('input.txt', 'r')
	input = f.readline

def mp():
	return list(map(int, input().split()))
m = 1000000007

def pow(k):
	if k == 0:
		return 1
	z = pow(k // 2)
	if k % 2 == 1:
		return 2 * z * z % m
	else:
		return z * z % m

def _main():
	(x, k) = mp()
	if x == 0:
		print(0)
		return
	t = pow(k)
	a = x * t
	b = a - t + 1
	print((a + b) % m)
_main()


MOD = 1000000007

def pow2(n):
	if n == 0:
		return 1
	t = pow2(n // 2) % MOD
	m = t * t % MOD
	if n % 2 == 1:
		m = m * 2 % MOD
	return m
(x, k) = map(int, input().split())
if x == 0:
	print(0)
	exit()
t = pow2(k) * (2 * x - 1) % MOD
print((t + 1) % MOD)


(x, k) = (int(x) for x in input().split())
mod = 10 ** 9 + 7
if x == 0:
	print(0)
	quit()
if k == 0:
	print(2 * x % mod)
	quit()
ans = pow(2, k + 1, mod)
ans *= x
ans %= mod
ans -= pow(2, k, mod)
ans += 1
ans %= mod
ans += mod
ans %= mod
print(ans)


import collections
from functools import cmp_to_key
import sys

def getIntList():
	return list(map(int, input().split()))
import bisect
base = 10 ** 9 + 7

def get2k(k):
	f = 2
	b = 1
	r = 1
	while k >= b:
		if k & b > 0:
			r = r * f % base
		b *= 2
		f = f * f % base
	return r
(x, k) = getIntList()
if x == 0:
	print(0)
	return
t2k = get2k(k)
r = x * t2k * 2 - t2k + 1
r = r % base
print(r)


(x, k) = map(int, input().split())
m = 10 ** 9 + 7
if x == 0:
	print(0)
	exit()
print((pow(2, k, m) * ((x - 1) % m) % m + pow(2, k, m) * x % m % m + 1 % m) % m)


def binPow(x, n, r):
	if n == 0:
		return 1
	elif n == 1:
		return x % r
	if n % 2 == 0:
		return binPow(x * x % r, n // 2, r)
	return binPow(x * x % r, n // 2, r) * x % r
(x, k) = list(map(int, input().split()))
r = 10 ** 9 + 7
if x == 0:
	print(0)
	return
elif k == 0:
	print(x * 2 % r)
	return
print((binPow(2, k, r) * (2 * x - 1) + 1) % r)


(x, k) = map(int, input().split())
MOD = 10 ** 9 + 7

def get(a, n):
	if n == 0:
		return 1
	if n % 2 == 1:
		return get(a, n - 1) * a % MOD
	else:
		b = get(a, n // 2) % MOD
		return b * b % MOD
if x == 0:
	print(0)
else:
	print((x * get(2, k + 1) - get(2, k) + 1) % MOD)


def powermod(base, power):
	if power == 0:
		return 1
	if power == 1:
		return base
	ret = powermod(base, power // 2)
	ret *= ret
	ret %= 1000000007
	if power % 2 == 1:
		ret *= base
		ret %= 1000000007
	return ret
(x, k) = list(map(int, input().split()))
b = x * 2 - 1
ans = b * powermod(2, k) + 1
ans %= 1000000007
if x == 0:
	ans = 0
print(ans)


(x, k) = map(int, input().split())
MOD = pow(10, 9) + 7

def repow(n):
	global MOD
	if n == 1:
		return 2
	if n % 2 == 0:
		return pow(repow(n // 2), 2) % MOD
	else:
		return 2 * pow(repow(n // 2), 2) % MOD
if 0 < k and 0 < x:
	if MOD <= k:
		while MOD <= k:
			k = k // MOD + k % MOD
	tmp = (2 * x - 1) % MOD
	print((tmp * repow(k) + 1) % MOD)
else:
	print(2 * x % MOD)


sp = 10 ** 9 + 7

def power(number, n):
	res = 1
	while n != 0:
		if n % 2 != 0:
			res *= number
			res %= sp
			n -= 1
		number *= number
		number %= sp
		n //= 2
	return res % sp
(x, k) = map(int, input().split())
if x == 0:
	print(0)
else:
	print((x % sp * power(2, k) % sp * 2 % sp - (power(2, k) - 1) % sp) % sp)


(n, k) = input().split()
n = int(n)
k = int(k)
m = 1000000007
z = pow(2, k, m)
ans = (2 * z * (n % m) % m - (z - 1)) % m
if n == 0:
	print(0)
else:
	print(ans)


from sys import stdin, exit

def listinput():
	return list(map(int, stdin.readline().rstrip().split()))
MOD = 10 ** 9 + 7
(x, k) = listinput()
if x == 0:
	print(0)
else:
	ans = (1 + (2 * x - 1) * pow(2, k, MOD)) % MOD
	print(ans)


M = 10 ** 9 + 7
R = lambda : map(int, input().split())
(x, k) = R()
if x == 0:
	print(0)
	quit()
print((pow(2, k + 1, M) * x % M - pow(2, k, M) + 1) % M)


from sys import stdin, stdout

def binary_exp(x, n, prime):
	if n == 0:
		return 1
	elif n == 1:
		return x % prime
	else:
		temp = binary_exp(x, n // 2, prime)
		temp = temp * temp % prime
		if n % 2 == 0:
			return temp
		else:
			return x % prime * temp % prime
(x, k) = map(int, stdin.readline().rstrip().split())
if x == 0:
	print(0)
else:
	val1 = binary_exp(2, k + 1, 1000000007)
	val2 = binary_exp(2, k, 1000000007)
	val1 = val1 % 1000000007
	val2 = val2 % 1000000007
	ans = (val1 * (x % 1000000007) % 1000000007 - (val2 - 1) % 1000000007) % 1000000007
	print(ans)


MOD = 1000 * 1000 * 1000 + 7

def pow(x, e, m):
	res = 1
	x = x % m
	while e > 0:
		if e % 2 == 1:
			res = res * x % m
		e = e // 2
		x = x * x % m
	return res
(x, k) = map(int, input().split(' '))
if x == 0:
	print(0)
else:
	myres = (pow(2, k, MOD) * (2 * x - 1) + 1) % MOD
	print(myres)


import sys
n = 10 ** 9 + 7

def smart_pow(k):
	if k == 0:
		return 1
	tmp = smart_pow(k // 2)
	if k % 2 == 0:
		return tmp * tmp % n
	else:
		return 2 * (tmp * tmp % n) % n

def main():
	(x, k) = map(int, sys.stdin.readline().split())
	if x == 0:
		print(0)
		return
	res = (2 * (x % n) % n - 1) % n
	resi = smart_pow(k)
	print((res * resi % n + 1) % n)
main()


MOD = 10 ** 9 + 7
(x, k) = map(int, input().split())
if not x:
	print(0)
else:
	aux = pow(2, k, MOD)
	resp = aux * 2 * x - aux + 1
	print(resp % MOD)


(n, k) = [int(i) for i in input().split()]
m = 10 ** 9 + 7
if n == 0:
	print(0)
else:
	print((n * pow(2, k + 1, m) - pow(2, k, m) + 1) % m)


MOD = 1000000007

def fast_power(base, power):
	result = 1
	while power > 0:
		if power % 2 == 1:
			result = result * base % MOD
		power = power // 2
		base = base * base % MOD
	return result
(x, k) = map(int, input().split())
if x == 0 or k == 0:
	print(x * 2 % MOD)
else:
	d = x * 4 - 1 - x * 2
	print((x * 2 + d * (fast_power(2, k) - 1)) % MOD)


(x, n) = map(int, input().split())
mod = 10 ** 9 + 7
if x > 0:
	ans = pow(2, n + 1, mod) * x - pow(2, n, mod) + 1
else:
	ans = 0
print(ans % mod)


(x, k) = list(map(int, input().split()))
m = 10 ** 9 + 7
if x == 0:
	print(0)
else:
	print((pow(2, k + 1, m) * x - pow(2, k, m) + 1) % m)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def power(a, b, z):
	if b == 0:
		return 1
	temp = power(a, b // 2, z)
	if b % 2 == 0:
		return temp * temp % z
	return a * temp * temp % z
(x, k) = list(map(int, input().split()))
if x == 0:
	print(0)
else:
	z = 10 ** 9 + 7
	n = power(2, k + 1, z) * x % z
	m = power(2, k, z)
	print((n - m + 1) % z)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(0, -1), (1, 0), (0, 1), (-1, 0)]
ddn = [(0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, -1), (-1, 0), (-1, 1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(x, k) = LI()
	if x == 0:
		return 0
	t = pow(2, k + 1, mod) * x % mod
	d = pow(2, k, mod) - 1
	return (t + mod - d) % mod
print(main())


modulo = 1000 ** 3 + 7

def mat_oz(x, k):
	if k == 0:
		return 2 * x % modulo
	if x == 0:
		return 0
	b = (pow(2, k, modulo) * (2 * x - 1) + 1) % modulo
	return b
(y, m) = [int(i) for i in input().split()]
print(mat_oz(y, m))


(x, k) = [int(v) for v in input().split()]
mod = 10 ** 9 + 7
if x == 0:
	print(0)
else:
	print((pow(2, k + 1, mod) * x - (pow(2, k, mod) - 1)) % mod)


m = 1000000007
(x, k) = map(int, input().split())
up = x * pow(2, k + 1, m) % m
down = pow(2, k, m) - 1
if x == 0:
	print(0)
else:
	print((up - down) % m)


(x, k) = map(int, input().split())
twoPow = pow(2, k, 1000000007)
minQ = max(0, x * twoPow - twoPow + 1)
minQ *= 2
maxQ = x * twoPow * 2
print((maxQ * (maxQ + 1) // 2 - minQ * (minQ + 1) // 2 + minQ) // (maxQ - minQ + 1) % 1000000007)


def pwr(a, n, m):
	if n == 0:
		return 1
	ans = pwr(a, n // 2, m)
	ans = ans * ans
	ans %= m
	if n % 2 == 1:
		return ans * a % m
	else:
		return ans
M = 1000000007
(tx, tn) = input().split()
x = int(tx)
n = int(tn)
ans = pwr(2, n + 1, M) * x
ans %= M
ans = ans - pwr(2, n, M) + 1
ans = (ans + M) % M
if x == 0:
	ans = 0
print(ans)


(x, k) = map(int, input().split())
if x == 0:
	print(0)
else:
	end = pow(2, k + 1, 1000000007)
	sum1 = (x * end - (end - 2)) % 1000000007
	sum2 = (sum1 + (pow(2, k, 1000000007) - 1)) % 1000000007
	print(sum2)


mod = 1000000007

def fastexp(base, exp):
	if exp == 0:
		return 1
	if exp == 1:
		return base % mod
	t = fastexp(base, exp // 2)
	if exp % 2 == 0:
		return t % mod * t % mod % mod
	else:
		return t % mod * t % mod * base % mod % mod
(x, k) = map(int, input().split())
if x == 0:
	print(0)
else:
	t = fastexp(2, k) % mod
	before = 2 * t % mod * x % mod % mod - (t + mod - 1) % mod
	while before < 0:
		before += mod
	before = before % mod
	print(before)


mod = 1000000007

def fast(a, b):
	if b == 0:
		return 1
	if b % 2 == 1:
		return a % mod * (fast(a, b - 1) % mod) % mod
	x = fast(a, b // 2) % mod
	return x * x % mod
(x, k) = map(int, input().split())
if x == 0:
	print(0)
else:
	z = (x % mod * (fast(2, k + 1) % mod) % mod - fast(2, k) % mod + mod + 1) % mod
	print(z)


MOD = int(1000000000.0) + 7

def fast_power(x, y):
	res = 1
	x %= MOD
	while y > 0:
		if y % 2 == 1:
			res = res * x % MOD
		x = x * x % MOD
		y = y >> 1
	return res
(x, k) = map(int, input().split())
if x == 0:
	print(0)
else:
	a = fast_power(2, k)
	b = (2 * x - 1) % MOD
	c = a * b % MOD + 1
	print(c % MOD)


MOD = 1000000007

def subtract(a, b):
	if b > a:
		a += MOD
	return (a - b) % MOD

def multiply(a, b):
	return a * b % MOD

def mpow(a, b):
	ret = 1
	while b is not 0:
		if b & 1:
			ret = multiply(ret, a)
		a = multiply(a, a)
		b = b >> 1
	return ret
i = input('')
[x, k] = [int(z) for z in i.split(' ')]
if x is 0:
	print(0)
else:
	ans = multiply(x, mpow(2, k + 1))
	temp = mpow(2, k)
	temp = subtract(temp, 1)
	ans = subtract(ans, temp)
	print(int(ans))


(x, k) = [int(x) for x in input().split()]
if x == 0:
	print(0)
	exit()
mod = 10 ** 9 + 7
res = x * pow(2, k + 1, mod) % mod
res = ((res - (pow(2, k, mod) - 1)) % mod + mod) % mod
print(res)


(x, y) = [int(x) for x in input().split()]
if x == 0:
	print(0)
else:
	print((x * pow(2, y + 1, 1000000007) - pow(2, y, 1000000007) + 1000000008 + 1000000007 * 1000000000) % 1000000007)


from sys import exit
mod = 10 ** 9 + 7
[x, k] = map(int, input().strip().split())
if x == 0:
	print(0)
	exit()

def pow2(n):
	if n == 0:
		return 1
	if n % 2 == 0:
		return pow2(n // 2) ** 2 % mod
	else:
		return pow2(n // 2) ** 2 % mod * 2 % mod
print((pow2(k) * ((2 * x - 1) % mod) + 1) % mod)


def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
(x, k) = map(int, input().split())
p = 1000000007
if x == 0:
	print('0')
else:
	t = (power(2, k, p) * ((2 * x - 1) % p) % p + 1) % p
	print(t)


(n, k) = map(int, input().split())
m = 1000000007
if n == 0:
	print(0)
	exit(0)
r = pow(2, k + 1, m) * n - pow(2, k, m) + 1
print(r % m)


def power(x, y):
	mod = 1000000007
	res = 1
	while y > 0:
		if y & 1:
			res = res * x % mod
		y = y >> 1
		x = x * x % mod
	return res
(x, k) = map(int, input().split())
mod = 1000000007
factor = power(2, k)
factor %= mod
ans = (2 * factor * x % mod - factor % mod + 1 + mod) % mod
if x == 0:
	print('0')
else:
	print(ans)


from math import log, floor

def twoton(n):
	if n < 30:
		return 2 ** n
	a = n // 2
	tmp = twoton(a)
	tt = tmp ** 2
	tt = tt % (10 ** 9 + 7)
	if n % 2 == 1:
		tt *= 2
	tt = tt % (10 ** 9 + 7)
	return tt
(x, k) = [int(i) for i in input().split()]
if x == 0:
	print(0)
else:
	t = twoton(k)
	print((x * 2 * t - t + 1) % (10 ** 9 + 7))


(X, K) = map(int, input().split())
mod = 1000000007
res = X * pow(2, K + 1, mod) - pow(2, K, mod) + 1
while res < 0:
	res += mod
if X == 0:
	print(0)
else:
	print(res % mod)


(x, k) = list(map(int, input().split()))
m = 1000000000 + 7
if x != 0:
	p1 = x * 2 - 1
	p2 = x * 2
	p = (p1 + p2) // 2
	print((p * pow(2, k, m) + 1) % m)
else:
	print(x * 2)


def bin(n):
	if n == 0:
		return 1
	elif n % 2 == 1:
		return bin(n - 1) * 2
	else:
		b = bin(n // 2) % 1000000007
		return b * b
(x, k) = map(int, input().split())
if x == 0:
	print(0)
else:
	z = bin(k + 1) % 1000000007
	z = z * (x - 1)
	z = z % 1000000007
	z += bin(k)
	z += 1
	while z < 0:
		z += 1000000007
	print(z % 1000000007)


def binar(a, st, d):
	if st == 0:
		return 1
	elif st == 1:
		return a % d
	return binar(a ** 2 % d, st // 2, d) * binar(a, st % 2, d) % d
(x, k) = map(int, input().split())
if x == 0:
	print(0)
	exit()
res = (x * binar(2, k + 1, 1000000007) - binar(2, k, 1000000007) + 1) % 1000000007
print(res)


def pow1(n, k):
	if k == 0:
		return 1
	if k == 1:
		return n
	elif k % 2 == 0:
		a = pow1(n, k // 2) % mod
		return a * a % mod
	else:
		return pow1(n, k - 1) % mod * n % mod
mod = 10 ** 9 + 7
(n, k) = map(int, input().split())
if n == 0:
	print(0)
else:
	x = pow1(2, k + 1) % mod
	print((n * x - pow1(2, k) + 1) % mod)


def mul(a, b, md):
	if b == 1:
		return a
	if b % 2 == 0:
		t = mul(a, b // 2, md)
		return 2 * t % md
	return (mul(a, b - 1, md) + a) % md

def pows(a, b, md):
	if b == 0:
		return 1
	if b % 2 == 0:
		t = pows(a, b // 2, md)
		return mul(t, t, md) % md
	return mul(pows(a, b - 1, md), a, md) % md
(x, k) = map(int, input().split())
ch = pows(2, k, 1000000007)
ans = pows(2, k + 1, 1000000007) * x - ch + 1
ans = ans % 1000000007
if x == 0:
	ans = 0
print(ans)


import os
import sys
from collections import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def egcd(a, b):
	if not a:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a, m=M):
	(g, x, y) = egcd(a, m)
	return x % m
(x, k) = value()
den = pow(2, k, M)
start = (x - 1 + M) % M * den % M
start = (start + 1) % M
num = start * den % M + den * ((den - 1 + M) % M) % M * modinv(2) % M
num = num * 2 % M
ans = num // den % M
ans = num * modinv(den) % M
if x == 0:
	ans = 0
print(ans)


mod = 10 ** 9 + 7

def power(a, b):
	ans = 1
	a = a % mod
	while b > 0:
		if b & 1:
			ans = ans * a % mod
		b = b // 2
		a = a * a % mod
	return ans
(x, k) = map(int, input().split())
ans = x * power(2, k + 1) - power(2, k) + 1 + mod
if x == 0:
	ans = 0
print(ans % mod)


(f1, f2) = map(int, input().split(' '))
if f1 == 0:
	print(0)
else:
	print((pow(2, f2, 1000000007) * (2 * f1 - 1) + 1) % 1000000007)


mod = 1000000007
import math

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def modInverse(b, m):
	g = math.gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def modDivide(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	a = a * inv % m
	return a
(n, k) = map(int, input().split())
ans = powm(4, k, mod) * n % mod
r = powm(2, k, mod)
r = (powm(r, 2, mod) - r) % mod
w = modDivide(r, 2, mod)
ans = ans - w
er = powm(2, k, mod)
ans = modDivide(ans, er, mod)
ans = ans * 2 % mod
if n == 0:
	ans = 0
print(ans)


m = int(1000000000.0 + 7)

def solve(x, k):
	return (m + pow(2, k, m) * x % m % m - (pow(2, k, m) - 1) % m * pow(2, m - 2, m) % m % m) % m
(x, k) = [int(x) for x in input().split()]
if x == 0:
	print(0)
elif k == 0:
	print((m + 2 * (x % m)) % m)
else:
	print((m + 2 * solve(x, k)) % m)


from sys import exit
(x, k) = map(int, input().split())
if x == 0:
	print(0)
	exit(0)
x = 2 * x - 1
mod = 10 ** 9 + 7

def pot(r, k):
	if k == 0:
		return 1
	if k % 2 == 1:
		return r * pot(r, k - 1) % mod
	y = pot(r, k // 2)
	return y * y % mod
print((pot(2, k) * x + 1) % mod)


(x, k) = map(int, input().strip().split())
c = False
if x == 0:
	print(0)
	c = True
m = 1000000007
x = x % m
p = pow(2, k, m)
x = x * p
y = (x - p + 1) % m
x = x % m
if c == False:
	print((x + y) % m)


(x, k) = [int(z) for z in input().split()]
MOD = 1000000007

def bigmod(a, b, m):
	ans = 1
	rem = a % m
	while b != 0:
		if b % 2 == 1:
			ans = ans * rem % m
		rem = rem * rem % m
		b //= 2
	return ans
if k == 0:
	print(x * 2 % MOD)
elif x == 0:
	print(0)
else:
	pot = bigmod(2, k, MOD)
	a0 = (x * pot % MOD - pot + 1) % MOD
	res = ((a0 * 2 % MOD + pot) % MOD - 1) % MOD
	print(res)


(x, k) = [int(i) for i in input().split()]
if x != 0:
	print((pow(2, k, 1000000007) * (2 * x - 1) + 1) % 1000000007)
else:
	print(0)


M = 10 ** 9 + 7
(x, k) = map(int, input().split())
if x == 0:
	print(0)
	exit(0)
P = pow(2, k, M)
r = P * x % M - 0.5 * (-1 + P) % M
print(int((2 * r + M) % M))


q = input().split()
x = int(q[0])
k = int(q[1])

def po(a, p, m):
	if p == 0:
		return 1
	x = po(a, p // 2, m) % m
	x = x % m * x % m % m
	if p % 2 == 1:
		x = x % m * a % m % m
	return int(x)
m = 1000000007
if x == 0:
	print(0)
else:
	print((po(2, k + 1, m) % m * x % m % m - (po(2, k, m) % m - 1) % m) % m)


(n, k) = map(int, input().split())
M = 1000000007
if n == 0:
	print(0)
else:
	ans = 2 * n - 1
	x = pow(2, k, M)
	print((ans * x % M + 1) % M)


(x, k) = map(int, input().split())
mod = 1000000007
flag = True
if x == 0:
	flag = False
x = x % mod
y = pow(2, k + 1, mod)
z = pow(2, k, mod) - 1
x = x * y
x = x % mod
x = x - z
if x == 0:
	x = x + mod
x = x % mod
if flag:
	print(x)
else:
	print(0)


MOD = 1000000007

def powr(n, N):
	temp = 1
	while N > 0:
		if N % 2 != 0:
			temp = temp * n % MOD
		n = n * n % MOD
		N = N // 2
	return temp % MOD

def MODI(a, b):
	ans = powr(a, b) % MOD
	return ans
(x, k) = map(int, input().split())
if x == 0:
	print(0)
else:
	t1 = powr(2, k + 1) % MOD
	t1 = t1 * x % MOD
	t2 = powr(2, k) % MOD
	t2 = (t2 - 1) % MOD
	ans = (t1 - t2) % MOD
	print(ans)


(x, k) = map(int, input().split())
if x == 0:
	result = 0
else:
	modulo = 10 ** 9 + 7
	x %= modulo
	result = pow(2, k, modulo) * (2 * x - 1) + 1
	result %= modulo
print(result)


(x, k) = map(int, input().split())
if x == 0:
	print(0)
	exit()
b = pow(2, k, 1000000007)
a = (2 * x - 1) % 1000000007
print((a * b + 1) % 1000000007)


def main():
	(n, k) = map(int, input().split())
	m = 10 ** 9 + 7
	print((pow(2, k, m) * (2 * n - 1) + 1) % m if n else 0)
main()


from itertools import combinations_with_replacement
import sys
from sys import stdin
import math
import bisect

def BinarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def iinput():
	return int(input())

def minput():
	return map(int, input().split())

def linput():
	return list(map(int, input().split()))

def fiinput():
	return int(stdin.readline())

def fminput():
	return map(int, stdin.readline().strip().split())

def flinput():
	return list(map(int, stdin.readline().strip().split()))
(x, k) = minput()
if x == 0:
	print(0)
else:
	mod = 10 ** 9 + 7
	a = pow(2, k, mod)
	b = (2 * x % mod - 1) % mod
	ans = (a * b % mod + 1) % mod
	print(ans)


(x, k) = map(int, input().strip().split())
MOD = 10 ** 9 + 7

def pow2(k):
	if k == 0:
		return 1
	if k == 1:
		return 2
	r = pow2(k // 2)
	r = r * r
	if k % 2 != 0:
		r *= 2
	return r % MOD

def calc(x, k):
	if x == 0:
		return 0
	if k == 0:
		return 2 * x % MOD
	r = pow2(k) * (2 * x - 1) + 1
	return r % MOD
print(calc(x, k))


def bin_pow(num, _pow, module):
	if _pow == 0:
		return 1
	if _pow == 1:
		return num % module
	if _pow % 2 == 1:
		return num * bin_pow(num, _pow - 1, module) % module
	res = bin_pow(num, _pow // 2, module)
	return res * res % module
(x, k) = map(int, input().split())
if x == 0:
	print(0)
	exit(0)
mod = 10 ** 9 + 7
__power = bin_pow(2, k, mod)
print((x * __power * 2 + 1 - __power) % mod)


def modexp(x, p):
	ans = 1
	while p > 0:
		if p % 2 == 1:
			ans = ans * x % 1000000007
		x = x * x % 1000000007
		p = p // 2
	return ans
s = input()
(x, k) = map(int, s.split())
mod = 1000000007
if x == 0:
	print(0)
else:
	print((modexp(2, k + 1) * x % mod - (modexp(2, k) - 1)) % mod)


(x, k) = list(map(int, input().split()))
if x == 0:
	print(0)
	return
x = 2 * x - 1
mod = 10 ** 9 + 7

def pot(r, k):
	if k == 0:
		return 1
	if k % 2 == 1:
		return r * pot(r, k - 1) % mod
	y = pot(r, k // 2)
	return y * y % mod
print((pot(2, k) * x + 1) % mod)


from math import pow

def modularExponentiation(x, n, M):
	if n == 0:
		return 1
	elif n % 2 == 0:
		return modularExponentiation(x * x % M, n // 2, M)
	else:
		return x % M * modularExponentiation(x * x % M, (n - 1) // 2, M) % M % M
c = 10 ** 9 + 7
(n, k) = map(int, input().split())
a = n % c * modularExponentiation(2, k + 1, c) % c % c
b = (modularExponentiation(2, k, c) % c - 1 % c + c) % c
if n == 0:
	print('0')
else:
	print((a % c - b % c + c) % c)


(x, k) = map(int, input().split())
ans = 0
md = 1000000007

def bpow(base, exp, md):
	if exp == 0:
		return 1
	if exp % 2 == 1:
		return base * bpow(base, exp - 1, md) % md
	else:
		k = bpow(base, exp // 2, md)
		return k * k % md
pw = bpow(2, k, md)
ans = 2 * pw * x % md
if x != 0:
	ans -= pw - 1
ans = (ans + md) % md
print(ans)


def pow(n):
	if n > 0:
		if n % 2 == 0:
			x = pow(n // 2) % 1000000007
			return x * x % 1000000007
		else:
			return pow(n - 1) * 2 % 1000000007
	else:
		return 1
(n, k) = map(int, input().split())
if n == 0:
	print(0)
else:
	print((pow(k) * (2 * n - 1) + 1) % 1000000007)


def pow_mod(x, pwr, mod):
	res = 1
	multiplier = x
	while pwr > 0:
		if pwr % 2 == 1:
			res = res * multiplier % mod
		multiplier = multiplier * multiplier % mod
		pwr //= 2
	return res
[x, k] = map(int, input().split())
MOD = 1000000007
if x == 0:
	res = 0
else:
	res = pow_mod(2, k + 1, MOD) * x % MOD
	res = (res - pow_mod(2, k, MOD)) % MOD
	res = (res + 1) % MOD
print(res)


(a, k) = input().split()
a = int(a)
k = int(k)
module = int(1000000000.0 + 7)
if a == 0:
	print(0)
	exit(0)
if k == 0:
	print(2 * a % module)
	exit(0)
a *= 2
ans = (a - 1) * pow(2, k, module) + 1
ans %= module
print(ans)


MOD = 1000000007

def modpow(x, p):
	result = 1
	while p > 0:
		if p % 2 == 1:
			result = result * x % MOD
		p = p // 2
		x = x * x % MOD
	return result
(n, k) = map(int, input().split())
k += 1
if n == 0:
	print(0)
else:
	ans = (modpow(2, k) * (n % MOD) % MOD - (modpow(2, k - 1) - 1) % MOD) % MOD
	print(ans)


M = 10 ** 9 + 7

def pw(x, y):
	r = 1
	x = x % M
	while y:
		if y & 1:
			r = r * x % M
		y = y >> 1
		x = x * x % M
	return r
(x, k) = map(int, input().split())
ans = pw(2, k + 1) * x - pw(2, k) + 1 + M
if x == 0:
	ans = 0
print(ans % M)


from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(x, k) = mapin()
p = 1000000007
if x == 0:
	print(0)
else:
	a = power(2, k, p)
	b = x + x - 1
	b %= p
	a = a * b % p
	a += 1
	a %= p
	print(a)


(x, k) = [int(a) for a in input().strip().split()]

def binpow(x, k, mod):
	res = 1
	while k > 0:
		if k & 1:
			res = res * x % mod
		x = x * x % mod
		k >>= 1
	return res
if x == 0:
	print(0)
	exit()
mod = int(1000000000.0 + 7)
k2 = binpow(2, k, mod)
res = (k2 * (2 * x - 1) + 1) % mod
res %= mod
print(int(res))


from sys import stdin, stdout
MOD = 10 ** 9 + 7

def bin_pow(n, k):
	res = 1
	while k:
		if k & 1:
			res = res * n % MOD
		n = n * n % MOD
		k >>= 1
	return res
(x, k) = map(int, stdin.readline().split())
if x == 0:
	stdout.write('0')
else:
	ans = (bin_pow(2, k + 1) * x - bin_pow(2, k) + 1) % MOD
	stdout.write(str(ans))


mod = 1000000007

def fast(x, wyk):
	if wyk == 0:
		return 1
	hf = fast(x, int(wyk // 2))
	hf = hf * hf % mod
	if wyk % 2 == 1:
		hf = hf * x % mod
	return hf
I = input().split()
x = int(I[0])
k = int(I[1])
res = x * fast(2, k + 1) - fast(2, k) + 1
res %= mod
if x == 0:
	res = 0
print(res)


(x, k) = map(int, input().split())
mod = 10 ** 9 + 7

def bp(n, p):
	if p == 0:
		return 1
	elif p % 2 == 0:
		return bp(n ** 2 % mod, p // 2)
	else:
		return bp(n ** 2 % mod, p // 2) * n % mod

def f(n, x):
	return (bp(2, n) * x - bp(2, n) + 1) % mod
if x > 0:
	print(f(k, 2 * x) % mod)
else:
	print(0)


(x, k) = map(int, input().split())
mod = 10 ** 9 + 7
e = x * pow(2, k, mod) % mod
s = (e - pow(2, k, mod)) % mod
f = lambda x: x * (x + 1) % mod
ans = (f(e) - f(s)) * pow(2, k * (mod - 2), mod) % mod
print(ans if x != 0 else 0)


(n, k) = map(int, input().split())
mod = int(1000000000.0 + 7)
if n > 0:
	ans = pow(2, k + 1, mod) * n - pow(2, k, mod) + 1
else:
	ans = 0
print(ans % mod)


from sys import stdin, stdout
from math import gcd
input = stdin.buffer.readline
(x, k) = map(int, input().split())
if x == 0:
	print(0)
	exit()
x *= 2
mod = 1000000007
x = pow(2, k, mod) * x % mod - (pow(2, k, mod) - 1)
print(x % mod)


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))
mod = 10 ** 9 + 7
(x, k) = mi()
if x == 0:
	print(0)
elif k == 0:
	print(2 * x % mod)
else:
	to = pow(2, k, mod)
	pre = to * x % mod
	prev = pow(2, k - 1, mod)
	first = (pre - prev + 1) % mod
	sec = (pre - prev) % mod
	ans = (first + sec) % mod
	print((ans + mod) % mod)


mod = 10 ** 9 + 7
[x, k] = list(map(int, input().strip().split()))
if x == 0:
	print(0)
	return

def pow2(n):
	if n == 0:
		return 1
	if n % 2 == 0:
		return pow2(n // 2) ** 2 % mod
	else:
		return pow2(n // 2) ** 2 % mod * 2 % mod
print((pow2(k) * ((2 * x - 1) % mod) + 1) % mod)


(x, k) = map(int, input().split())
MOD = 1000000007
invOf2 = pow(2, MOD - 2, MOD)
if x == 0:
	print(0)
else:
	powOf2 = pow(2, k, MOD)
	invPowOf2 = pow(powOf2, MOD - 2, MOD)
	s = ((powOf2 * (x % MOD) % MOD - (powOf2 - 1) % MOD) % MOD - 1) % MOD
	e = powOf2 * (x % MOD) % MOD
	se = e * (e + 1) % MOD * invOf2 % MOD
	ss = s * (s + 1) % MOD * invOf2 % MOD
	ans = (se - ss) % MOD * 2 % MOD * invPowOf2 % MOD
	print(ans)


M = 10 ** 9 + 7
(x, k) = [int(i) for i in input().split()]
if x == 0:
	print(0)
elif k == 0:
	print(x * 2 % M)
else:
	top_sum = pow(2, k, M) % M * ((2 * x - 1) % M) % M + 1
	print(top_sum % M)


def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
(d, n) = map(int, input().split())
ans = power(2, n + 1, 1000000007)
ans1 = power(2, n, 1000000007)
if d == 0:
	print(0)
else:
	print((ans * (d % 1000000007) % 1000000007 - ans1 + 1) % 1000000007)


(x, k) = map(int, input().split())
if x == 0:
	print(0)
	return
res = pow(2, k + 1, 10 ** 9 + 7) * x - pow(2, k, 10 ** 9 + 7) + 1
res %= 10 ** 9 + 7
print(res)