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