n,m = [int(i) for i in input().split()]
if n==1 or m==1:
    if max(n,m)>4:
        if max(n,m)%2==0:
            print(9)
        else:
            print(8)
    else:
        print(2*max(n,m))
else:
    print(int(pow(2,max(n,m),1000000007)))
