main = do
    str <- getLine
    let [a, b] = map read $ words $ str :: [Integer]
    let i2b =  i2b' where i2b' 0 = []; i2b' n = mod n 2 : i2b' (div n 2)
    let toMod x = x `mod` 1000000007
    let ans = foldl (\x y -> toMod (x * y) ) 1 $ filter (/=0) $ zipWith (*) (iterate (toMod . (^2) ) a) $ i2b b
    putStrLn $ show ans