#include <bits/stdc++.h>
using namespace std;
int power(int x, int y, int p) {
  int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  if (m == 1 && n == 1) {
    cout << 2 << "\n";
    return 0;
  }
  cout << 2 + (2 * (m - 3) * power(2, m - 4, 1000000007) +
               2 * power(2, m - 3, 1000000007) +
               (n - 3) * power(2, n - 4, 1000000007) +
               2 * power(2, n - 3, 1000000007));
  return 0;
}
