import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.io.ObjectInputStream.GetField;
import java.security.KeyStore.Entry;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class codeforcesreturn {
	public static class Pair implements Comparable<Pair> {
		int start;
		int end;

		public Pair(int start, int end) {
			super();
			this.start = start;
			this.end = end;
		}

		@Override
		public int compareTo(Pair p) {
			if (start == p.start)
				return end - p.end;
			return start - p.start;
		}

	}

	public static class UnionFind {
		int[] p, rank;
		boolean[] cyclic;

		public UnionFind(int N) {
			p = new int[N];
			rank = new int[N];
			// cyclic = new boolean[N];
			for (int i = 0; i < N; i++)
				p[i] = i;
		}

		public int findSet(int x) {
			return p[x] == x ? x : (p[x] = findSet(p[x]));
		}

		public boolean isunioned(int x, int y) {
			return findSet(x) == findSet(y);
		}

		public boolean union(int x, int y) {
			x = findSet(x);
			y = findSet(y);
			if (x == y) {
				return false;
			}
			if (rank[x] > rank[y])
				p[y] = x;
			else {
				p[x] = y;
				if (rank[x] == rank[y])
					++rank[y];
			}
			return true;
		}
	}

	static TreeSet<Integer>[] adjlist;
	static int[][] adjmatrix;
	static int[][] adjmatrix2;
	static boolean[] vis;
	static boolean[] intialvis;
	static boolean[] vis2;
	static Stack<Integer> st;
	static ArrayList<Integer> arrylist;
	static boolean flag;
	static int[] dx = new int[] { 1, -1, 0, 0 };
	static int[] dy = new int[] { 0, 0, 1, -1 };
	static boolean ans = true;;
	static int[] dist, parent;
	static boolean[] visited;
	static int src, dest;

	public static long gcd(long u, long v) {
		if (u == 0)
			return v;
		return gcd(v % u, u);
	}

	static long pow(long a, long n) {
		long res = 1;
		while (n != 0) {
			if ((n & 1) == 1){
				res *= a;
				res%=1e9+7;
			}
			a = (long) ((a*a)%(1e9+7));
			n >>= 1;
		}
		return res;
	}

	static ArrayList<Integer>[] adjList;
	static int V, E, counter[], c, SCC, dfs_num[], dfs_low[], Arr[];
	static int[] inSCC, cost;
	static Stack<Integer> stack;
	static PrintWriter pw;
	static long minn = 0, num = 1;

	public static void main(String[] args) throws IOException, InterruptedException {
		// FileWriter f = new FileWriter("C:\\Users\\Hp\\Desktop\\out.txt");
		// PrintWriter pw = new PrintWriter(f);
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long m=sc.nextLong();
		if(n<2||m<2){
			System.out.println(pow(2, n*m));
			return;
		}
		double ans=3+(m-1)*(n-1)*0.5;
		ans%=(1e9+7);

		ans+=(n*m-4-(m-1)*(n-1))*10.0/32;
		ans%=(1e9+7);
		System.out.println((long)ans*2);
		pw.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

}