import java.util.Scanner;

public class TaskC {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		int m = s.nextInt();
		final long MOD = 1000000007;
		
		long ans = pow2(2,m,MOD);
		ans = ((ans + MOD) - gauss(m-2))%MOD;
		long vert =	pow2(2,n-3,MOD);
		vert = ((vert + MOD) - gauss(n-5))%MOD;
		long a = (vert + ans)%MOD;
		
		System.out.println(a);
	}
	
	public static long pow2(long a, long b, long MOD) {
        long re = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                re = (re * a)%MOD;        
            }
            b >>= 1;
            a  = (a*a)%MOD; 
        }
        return re;
    }
	
	public static long gauss(long n) {
		if(n <= 0) {
			return 0;
		}
		return (n * (n+1))/2;
	}
}
