module Main open System let t = Console.ReadLine() |> int let ss = [for _ in 1..t -> [for c in Console.ReadLine() -> String.Concat([c]) |> int] ] let rec calc = function | (x :: y :: zs) -> let xy = x + y let r = xy / 10 let m = xy % 10 let n = if r > 0 then r + m else m n :: calc (y :: zs) | _ -> [] let rec solve = function | [x] -> x | xs -> solve <| calc xs for s in ss do Console.WriteLine(solve s)