main = getContents >>= print . solve . map read . lines solve :: [Int] -> Int solve [n, m] = foldl (\x acc -> mod (acc * x) 10) 1 $ replicate m n