import Control.Applicative

main :: IO ()
main = do
  [n, m] <- map read . words <$> getLine :: IO [Int]
  print $ solve n m

solve :: Int -> Int -> Int
solve a b = go a b
  where
    go x y
      | y == 0 = 1
      | y `mod` 2 == 0 = go (multMod x x) (y `div` 2)
      | otherwise = multMod x $ go x (y - 1)

multMod :: Int -> Int -> Int
multMod x y = (x * y) `mod` 1000000007