func (_:_:(-1):_) = []
func (a:b:n:_) = let m = a`div`b
             in m : (func [((a-(m*b))*10), b, (n-1)])

main = do{
    getContents>>=mapM_ print.map (sum.tail.func.map (read::String->Int).words).lines;
}