package no3308_one_time_changed_fomula; import java.util.*; public class Main { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); StringBuilder sb = new StringBuilder(); while(t > 0) { int n = sc.nextInt(); String s = "+"; s += sc.next(); s += '+'; int ind = 0; long ans = 0; boolean befMinus = false; while(ind != n + 1) { long num = 0; boolean plus = s.charAt(ind) == '+'; if(ind != 0 && !befMinus)ans += 9; ind++; while(s.charAt(ind) != '+' && s.charAt(ind) != '-'){ char c = s.charAt(ind); if(c != '*' && plus) { num += '9' - c; }else if(c != '*' && !plus) { num += c - '1'; } else if(plus) { num += 9; }ind++; }ans += num; befMinus = !plus; } sb.append(ans + "\n"); t--; }System.out.print(sb); } }