import Data.Maybe (fromJust) import qualified Data.ByteString.Char8 as BSC8 readInts :: IO [Integer] readInts = map (fst . fromJust . BSC8.readInteger) . BSC8.words <$> BSC8.getLine pw :: Integer -> Integer -> Integer pw s 0 = 1 pw 1 _ = 1 pw s k | even k = z * z | otherwise = s * z * z where z = pw s (k `div` 2) main :: IO () main = do (s:k:_) <- readInts print $ (pw s k) `mod` 1000000007