main = do
    str <- getLine
    let [a, b] = map read $ words $ str :: [Int]
    solve a b
solve :: Int -> Int -> IO ()
solve a b = do
    if (b /= 1)
        then if (odd b)
            then do solve ((a * a * 2) `mod` 1000000007) (b `div` 2)
            else solve ((a * a) `mod` 1000000007) (b `div` 2)
        else do  putStrLn $ show a