#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
inline int read() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
inline int qpow(int x, int y = MOD - 2) {
  long long r = 1, k = x;
  for (; y; y >>= 1, k *= k, k %= MOD)
    if (y & 1) r *= k, r %= MOD;
  return r;
}
int main() {
  int n = read(), m = read();
  int ans = qpow(n * 2 + 2, m);
  ans = 1ll * ans * (n + 1 - m) % MOD;
  printf("%lld\n", 1ll * ans * qpow(n + 1) % MOD);
  return 0;
}
