tuplify :: [Integer] -> (Integer, Integer)
tuplify [x, y] = (x, y)

solve :: Integer -> Integer -> Integer
solve x y = x^y `mod` 1000000007

main = do
    a <- getLine
    putStrLn $ show $ uncurry solve $ tuplify (map read (words a) :: [Integer])