#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, o;       string s;       cin >> n >> s;       o = s[n - 1] -  0 ;       for (int i = 0; i < n - 1; i++) o += (s[i] ==  0  ? 0 : s[i] - 47);       cout << o << endl;     }     return 0;   }   