import Control.Monad import Data.Char main :: IO () main = do t <- read <$> getLine replicateM_ t $ do s <- getLine putStrLn $ show $ solve $ map digitToInt s solve :: [Int] -> Int solve (s:[]) = s solve ss = solve s3 where s1 = take ((length ss) - 1) ss s2 = drop 1 ss next c = c `div` 10 + c `mod` 10 s3 = zipWith (\a b -> if a + b >= 10 then next $ a+b else a + b) s1 s2