#include <bits/stdc++.h>
using namespace std;
#define int long long

inline int read() {
	int x = 0, f = 0; char c = 0;
	while (!isdigit(c)) f |= c == '-', c = getchar();
	while (isdigit(c)) x = x * 10 + (c & 15), c = getchar();
	return f ? -x : x;
}

signed main() {
	freopen("barrack.in", "r", stdin);
	freopen("barrack.out", "w", stdout);
	int n = read(), m = read();
	int P = 1e9 + 7, hzy = 1, res = 0;
	for (int i = 1; i <= n - 2; i ++) {
		hzy = hzy * 2ll % P;
	}
	for (int i = 1; i <= n; i ++) {
		res = (res + hzy * (i + 1) % P) % P;
	}
	cout << res << endl;
	return 0;
}