#include<stdio.h>
int main()
{
	int n,m;
	int mod=1e9+7;
	while(~scanf("%d%d",&n,&m))
	{
		int ans=1;
		while(m)
		{
			if(m%2)
				ans=(ans*n)%mod;
			m/=2;
			n=(n*n)%mod;
		}
		printf("%d\n",ans);
	}
	return 0;
}