main :: IO () main = do n <- readLn :: IO Integer m <- readLn :: IO Integer print $ if m `mod` 2 /= 0 && m `mod` 5 /= 0 then -1 else last $ n`divL`m divL :: Integer -> Integer -> [Integer] divL n m | n == 0 = [] | otherwise = n`div`m:divL (n`mod`m*10) m