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

solve :: (Int, Int) -> Int
solve (x, y) = x^y `mod` 1000000007


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