description: You are given a digital clock with n digits. Each digit shows an integer from 0 to 9, so the whole clock shows an integer from 0 to 10^n-1. The clock will show leading zeroes if the number is smaller than 10^{n-1}.
  
  You want the clock to show 0 with as few operations as possible. In an operation, you can do one of the following: 
  
    * decrease the number on the clock by 1, or 
    * swap two digits (you can choose which digits to swap, and they don't have to be adjacent). 
  
  
  
  Your task is to determine the minimum number of operations needed to make the clock show 0.
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 10^3).
  
  The first line of each test case contains a single integer n (1 ≤ n ≤ 100) — number of digits on the clock.
  
  The second line of each test case contains a string of n digits s_1, s_2, …, s_n (0 ≤ s_1, s_2, …, s_n ≤ 9) — the number on the clock.
  
  Note: If the number is smaller than 10^{n-1} the clock will show leading zeroes.
  
  Output
  
  For each test case, print one integer: the minimum number of operations needed to make the clock show 0.
  
  Example
  
  Input
  
  
  7
  3
  007
  4
  1000
  5
  00000
  3
  103
  4
  2020
  9
  123456789
  30
  001678294039710047203946100020
  
  
  Output
  
  
  7
  2
  0
  5
  6
  53
  115
  
  Note
  
  In the first example, it's optimal to just decrease the number 7 times.
  
  In the second example, we can first swap the first and last position and then decrease the number by 1.
  
  In the third example, the clock already shows 0, so we don't have to perform any operations.
solution:                         /*
                          TO LEARN
                  
                          2-euler tour
                      
                          */
                          /*
                          TO SOLVE 
                          codeforces 722 kavi on pairing duty
                          */
                          /*
                          bit manipulation shit
                          1-Computer Systems: A Programmer's Perspective
                          2-hacker's delight
                          3-(02-03-bits-ints)
                          4-machine-basics
                          5-Bits Manipulation tutorialspoint
                          */
                          /*
                          TO WATCH
                          
                          */
                                      import java.util.*;
                                      import java.math.*;
                                      import java.io.*; 
                                      import java.util.stream.Collectors;
  
                                         public class B{
                                      static FastScanner scan=new FastScanner();
                                       public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));            
                      public static void main(String[] args)  throws Exception 
                                {
                           
  
                               //      scan=new FastScanner("D:\\usaco test data\\W.txt");
                               // out = new PrintWriter("D:\\usaco test data\\WW.txt");
                                   
                                                               /*
                                   READING 
                              
                                   3-Introduction to DP with Bitmasking codefoces
                                   4-Bit Manipulation hackerearth
                                   5-read more about mobious and inculsion-exclusion 
                                   */
                                   /*
                                   if it has no Xs or Os then the answer is 0
                                 
                                   */
                                  
                                      int tt=1;
                                    
                   tt=scan.nextInt();
                      int T=1;
                                     //System.out.println(8|9);
                    
                               outer:while(tt-->0)
                                      {
                                          int n=scan.nextInt();
                                          StringBuilder s=new StringBuilder(scan.next());
                                          long res=0;
                                         for(int i=n-1;i>=0;i--)
                                         {
                                          if(s.charAt(i)-'0'>0)
                                          {
                                               res+=(s.charAt(i)-'0');
                                              for(int j=i-1;j>=0;j--)
                                              {
                                                  if(s.charAt(j)-'0'>0)
                                                  {
                                                      res++;
                                                      res+=(s.charAt(j)-'0');
                                                      s.setCharAt(j,'0');
                                                     // break;
                                                  }
                                              }
                                              break; 
  
                                          }
                                          else 
                                          {
  
                                              //  res+=(s.charAt(i)-'0');
                                              for(int j=i-1;j>=0;j--)
                                              {
                                                  if(s.charAt(j)-'0'>0)
                                                  {
                                                      res++;
                                                      res+=(s.charAt(j)-'0');
                                                      s.setCharAt(j,'0');
                                                     // break;
                                                  }
                                              }
                                              break;                                      }
                                         }
                                         out.println(res);
                                    }
                                  
  
                                  
  
          out.close();
                      }
                    
                                      
                                     
                                       static long binexp(long a,long n)
                                      {
                                          if(n==0)
                                              return 1;
                                          long res=binexp(a,n/2);
                                          if(n%2==1)
                                              return res*res*a;
                                          else 
                                              return res*res;
                                      }
                                       
                                      static long powMod(long base, long exp, long mod) {
                                             if (base == 0 || base == 1) return base;
                                             if (exp == 0) return 1;
                                             if (exp == 1) return (base % mod+mod)%mod;
                                             long R = (powMod(base, exp/2, mod) % mod+mod)%mod;
                                             R *= R;
                                             R %= mod;
                                             if ((exp & 1) == 1) {
                                                 return (base * R % mod+mod)%mod;
                                             }
                                             else return (R %mod+mod)%mod;
                                         }
                                      static double dis(double x1,double y1,double x2,double y2)
                                      {
                                          return Math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
                                      }
                                      static long mod(long x,long y)
                                          {
                                              if(x<0)
                                                  x=x+(-x/y+1)*y;
                                              return x%y;
                                          }
                                       public static  long pow(long b, long e) {
                                                  long r = 1;
                                                  while (e > 0) {
                                                      if (e % 2 == 1) r = r * b ;
                                                      b = b * b;
                                                      e >>= 1;
                                                  }
                                                  return r;
                                              }
                                      private static void sort(long[] arr) {
                                              List<Long> list = new ArrayList<>();
                                              for (long object : arr) list.add(object);
                                              Collections.sort(list);
                                          //Collections.reverse(list);
                                              for (int i = 0; i < list.size(); ++i) arr[i] = list.get(i);
                                          }
                                      private static void sort2(int[] arr,int l,int r) {
                                              List<Integer> list = new ArrayList<>();
                                              for(int i=l;i<=r;i++) {
                                             //     System.out.println(arr.length+" "+l+" "+r);
                                                  list.add(arr[i]);
                                              }
                                              Collections.sort(list);
                                          Collections.reverse(list);
                                              for (int i = l; i <=r; ++i) arr[i] = list.get(i-1);
                                          }
                                       static class FastScanner
                          {
                              private int BS = 1 << 16;
                              private char NC = (char) 0;
                              private byte[] buf = new byte[BS];
                              private int bId = 0, size = 0;
                              private char c = NC;
                              private double cnt = 1;
                              private BufferedInputStream in;
                           
                              public FastScanner() {
                                  in = new BufferedInputStream(System.in, BS);
                              }
                           
                              public FastScanner(String s) {
                                  try {
                                      in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
                                  } catch (Exception e) {
                                      in = new BufferedInputStream(System.in, BS);
                                  }
                              }
                           
                              private char getChar() {
                                  while (bId == size) {
                                      try {
                                          size = in.read(buf);
                                      } catch (Exception e) {
                                          return NC;
                                      }
                                      if (size == -1) return NC;
                                      bId = 0;
                                  }
                                  return (char) buf[bId++];
                              }
                           
                              public int nextInt() {
                                  return (int) nextLong();
                              }
                           
                              public int[] nextInts(int N) {
                                  int[] res = new int[N];
                                  for (int i = 0; i < N; i++) {
                                      res[i] = (int) nextLong();
                                  }
                                  return res;
                              }
                           
                              public long[] nextLongs(int N) {
                                  long[] res = new long[N];
                                  for (int i = 0; i < N; i++) {
                                      res[i] = nextLong();
                                  }
                                  return res;
                              }
                           
                              public long nextLong() {
                                  cnt = 1;
                                  boolean neg = false;
                                  if (c == NC) c = getChar();
                                  for (; (c < '0' || c > '9'); c = getChar()) {
                                      if (c == '-') neg = true;
                                  }
                                  long res = 0;
                                  for (; c >= '0' && c <= '9'; c = getChar()) {
                                      res = (res << 3) + (res << 1) + c - '0';
                                      cnt *= 10;
                                  }
                                  return neg ? -res : res;
                              }
                           
                              public double nextDouble() {
                                  double cur = nextLong();
                                  return c != '.' ? cur : cur + nextLong() / cnt;
                              }
                           
                              public double[] nextDoubles(int N) {
                                  double[] res = new double[N];
                                  for (int i = 0; i < N; i++) {
                                      res[i] = nextDouble();
                                  }
                                  return res;
                              }
                           
                              public String next() {
                                  StringBuilder res = new StringBuilder();
                                  while (c <= 32) c = getChar();
                                  while (c > 32) {
                                      res.append(c);
                                      c = getChar();
                                  }
                                  return res.toString();
                              }
                           
                              public String nextLine() {
                                  StringBuilder res = new StringBuilder();
                                  while (c <= 32) c = getChar();
                                  while (c != '\n') {
                                      res.append(c);
                                      c = getChar();
                                  }
                                  return res.toString();
                              }
                           
                              public boolean hasNext() {
                                  if (c > 32) return true;
                                  while (true) {
                                      c = getChar();
                                      if (c == NC) return false;
                                      else if (c > 32) return true;
                                  }
                              }
                          }
  
                                       static class Pair implements Comparable<Pair>{
                                                      public long x, y,z;
                                                      public Pair(long x1, long y1,long z1) {
                                                          x=x1;
                                                          y=y1;
                                                          z=z1;
                                                      }
                                                       public Pair(long x1, long y1) {
                                                          x=x1;
                                                          y=y1;
                                              
                                                      }
                                                      
                                                      @Override
                                                      public int hashCode() {
                                                          return (int)(x + 31 * y);
                                                      }
                                                      public String toString() {
                                                          return x + " " + y+" "+z;
                                                      }
                                                      @Override
                                                      public boolean equals(Object o){
                                                          if (o == this) return true;
                                                          if (o.getClass() != getClass()) return false;
                                                          Pair t = (Pair)o;
                                                          return t.x == x && t.y == y&&t.z==z;
                                                      }
                                              public int compareTo(Pair o)
                                              {
                                                  if(x==o.x)
                                                      return (int)(o.y-y);
                                                                              
                                        
                                                  return (int)(x-o.x);
                                               
                                                  }
                                               
                                              }
  
                                      
                                      }
  
                                       
  