func main() var T: int :: cui@input().toInt(&) for(1, T) do solve(cui@input()) end for func solve(S: []char) var n: int :: ^S var old: []int :: #[n]int for i(0, ^S - 1) do old[i] :: S[i] $ int - '0' $ int end for while(n > 1) var new: []int :: #[n - 1]int for i(0, n - 2) do new[i] :: old[i] + old[i + 1] do new[i] :: new[i] / 10 + new[i] % 10 end for do old :: ##new do n :- 1 end while var ans: int :: old[0] do cui@print("\{ans}\n") end func end func