import Data.Int

main = getLine >>= print . solve 1 . map (read :: String -> Int64) . words

solve :: Int64 -> [Int64] -> Int64
solve ans [_, 0] = ans
solve ans [n, m] = if m `mod` 2 == 1
                   then solve (ans * n `mod` 1000000007) [n * n, m `div` 2]
                   else solve ans [n * n, m `div` 2]