T=int(input()) for tests in range(T): N=int(input()) S=input().strip() ANS=0 now=1 for x in S: if "0"<=x<="9": k=int(x) if now==1: ANS+=9-k else: ANS+=k-1 elif x=="+": if now==1: ANS+=9 now=1 elif x=="-": if now==1: ANS+=9 now=0 else: if now==1: ANS+=9 print(ANS)