#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
inline istream& operator>>(istream& str, pair<T, U>& p) {
  return str >> p.first >> p.second;
}
template <class T>
inline istream& operator>>(istream& str, vector<T>& a) {
  for (auto& i : a) str >> i;
  return str;
}
const long long N = 1e6 + 10, mod = 1e9 + 7;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long dd[m + 1][5];
  memset(dd, 0, sizeof dd);
  long long d[m + 1][2];
  dd[0][0] = 0, dd[0][1] = 0;
  d[1][0] = 1, dd[1][1] = 1;
  for (long long i = 2; i <= m; i++) {
    dd[i][0] = (dd[i - 2][0] % mod + dd[i - 1][1] % mod) % mod;
    dd[i][1] = (dd[i - 2][1] % mod + dd[i - 1][0] % mod) % mod;
  }
  if (n == 1) {
    cout << (dd[m][0] + dd[m][1]) % mod;
    return 0;
  }
  dd[1][0] = 1, dd[1][1] = 1, dd[1][2] = 1, dd[1][3] = 1;
  dd[2][0] = 1, dd[2][1] = 1, dd[2][2] = 2, dd[2][3] = 2;
  for (long long i = 3; i <= m; i++) {
    dd[i][0] = dd[i - 1][1];
    dd[i][1] = dd[i - 1][0];
    dd[i][2] = (dd[i - 2][2] % mod + dd[i - 1][3] % mod) % mod;
    dd[i][3] = (dd[i - 2][3] % mod + dd[i - 1][2] % mod) % mod;
  }
  long long ans =
      (dd[m][0] % mod + dd[m][1] % mod + dd[m][2] % mod + dd[m][3] % mod) % mod;
  for (long long i = 3; i <= n; i++) {
    ans = (ans * 2) % mod;
  }
  cout << ans;
}
