package main import . "fmt" import . "os" import bf "bufio" func main() { rd := bf.NewReader(Stdin) var t int Fscan(rd, &t) for ; t > 0; t-- { var n int var s string Fscan(rd, &n, &s) plus := true c := 0 for _, ch := range s { switch ch { case '+': if plus { c += 9 } plus = true case '-': if plus { c += 9 } plus = false case '*': if plus { c += 9 } default: v := int(ch) - '0' if plus { c += 9 - v } else { c += v - 1 } } } Println(c) } }