main = getContents >>= print . solve . map read . lines solve :: [Integer] -> Integer solve [n, m] = (n^m) `mod` 10