#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long quickPowMod(long long a, long long b, long long m) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = ans * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return ans;
}
int main() {
  long long n, m;
  scanf("%lld%lld", &n, &m);
  if (n > m) {
    long long t = n;
    n = m;
    m = t;
  }
  long long res = quickPowMod(2, n, mod);
  if (m <= 2)
    res = (res + (quickPowMod(2, m, mod) - 2 + mod) % mod) % mod;
  else
    res = (res + (3 * quickPowMod(2, m - 2, mod) - 2 + mod) % mod) % mod;
  printf("%lld\n", res);
  return 0;
}
