n, m = [int(i) for i in input().split()]
f = [1, 1]
mod = 1000000007
c1 = 9 * pow(4, mod - 2, mod)
c2 = 3 * pow(2, mod - 2, mod)
for i in range(100005):
    f.append((f[-1] + f[-2])%mod)

if n < 3 or m < 3:
    if n < m:
        n, m = m, n
    if m == 1:
        ans = 2 * f[n]
    else:
        ans = 2 + 2 * f[n]
    
elif n & 1:
    M = n // 2 + 1
    l = m - 1
    ans = c1 * pow(2, M, mod) * pow(f[l], M, mod)
else:
    M = n // 2 - 1
    l = m - 1
    ans = pow(2, M+1, mod) * c2 * pow(f[l], M, mod) * (2 + 2*f[l+1])

print(ans%mod)


