There is an airplane which has n rows from front to back. There will be m people boarding this airplane.

This airplane has an entrance at the very front and very back of the plane.

Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then board the plane one by one starting with person 1. Each person can independently choose either the front entrance or back entrance to enter the plane.

When a person walks into the plane, they walk directly to their assigned seat and will try to sit in it. If it is occupied, they will continue walking in the direction they walked in until they are at empty seat - they will take the earliest empty seat that they can find. If they get to the end of the row without finding a seat, they will be angry.

Find the number of ways to assign tickets to the passengers and board the plane without anyone getting angry. Two ways are different if there exists a passenger who chose a different entrance in both ways, or the assigned seat is different. Print this count modulo 10^9 + 7.


-----Input-----

The first line of input will contain two integers n, m (1 ≤ m ≤ n ≤ 1 000 000), the number of seats, and the number of passengers, respectively.


-----Output-----

Print a single number, the number of ways, modulo 10^9 + 7.


-----Example-----
Input
3 3

Output
128



-----Note-----

Here, we will denote a passenger by which seat they were assigned, and which side they came from (either "F" or "B" for front or back, respectively).

For example, one valid way is 3B, 3B, 3B (i.e. all passengers were assigned seat 3 and came from the back entrance). Another valid way would be 2F, 1B, 3F.

One invalid way would be 2B, 2B, 2B, since the third passenger would get to the front without finding a seat.

Source: codeforces | Difficulty: VERY_HARD
Tags: Number theory

Mathematics


Solutions:
(n, m) = [int(i) for i in input().split()]
print(pow(2 * n + 2, m - 1, 1000000007) * 2 * (n + 1 - m) % 1000000007)


MOD = 10 ** 9 + 7
(n, m) = input().split(' ')
n = int(n)
m = int(m)
ans = pow(2 * (n + 1), m, MOD)
ans = ans * (n + 1 - m) % MOD
ans = ans * pow(n + 1, MOD - 2, MOD) % MOD
print(ans)


mod = 1000000007

def power(a, p):
	res = 1
	while p > 0:
		if p % 2 == 1:
			res = res * a % mod
		a = a * a % mod
		p //= 2
	return res
(n, m) = map(int, input().split())
n += 1
res = power(n * 2, m - 1) * (n - m) * 2
print(res % mod)