

#Author: ghoshashis545 -Ashis Ghosh
from __future__ import division, print_function
 
import os,sys
from io import BytesIO, IOBase
import collections
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
 
 
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())
mod=1000000007
#mod=998244353
inf = float("inf")
def powerMod(x,y,p):
    res = 1
    x %= p
    while y > 0:
        if y&1:
            res = (res*x)%p
        y = y>>1
        x = (x*x)%p
    return res
 
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
def isPrime(n) : # Check Prime Number or not 
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) : 
        if (n % i == 0 or n % (i + 2) == 0) : 
            return False
        i = i + 6
    return True

n,m=mi()
if(n>m):
    t=m
    m=n
    n=t
ans=powerMod(n,m,mod)
print(ans)



 
 