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