
import java.util.*;

public class IvanTheFool {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		long ans = 1;

		if (n == 1 || m == 1) {
			if (n == 1) {
				ans = m * 2;
			} else {
				ans = n * 2;
			}
		} else {

			for (int i = 0; i < m; i++) {
				ans = (ans * n)%1000000007;
			}
		}
		ans=ans%1000000007;
		System.out.println(ans);

	}

}
