import java.util.*;
public class p1 {

    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long m=sc.nextLong();
        long ans=1;

        if(n==0)
        {
            System.out.println("0");
            return;
        }

        long a1=n*m+1;
        a1=a1/2;

        while(a1>0)
        {
            ans=(n*ans)%1000000007;
            a1-=1;
        }
        System.out.println(ans);

    }

}
