func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long int mod = 1000000007;   const long long int inf = 9e18;   void __print(long long int x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     long long int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   void tc() {     long long int n;     cin >> n;     string a, b;     cin >> a >> b;     for (long long int i = 0; i < n; i++) {       if (a[i] > b[i]) {         cout << -1 << endl;         return;       }     }     long long int ans = 0;     for (char ch =  a ; ch <=  z ; ch++) {       set<long long int> idx;       char mini =  z ;       for (long long int i = 0; i < n; i++) {         if (a[i] == ch && a[i] != b[i]) {           idx.insert(i);           mini = min(mini, b[i]);         }       }       bool done = false;       for (auto it = idx.begin(); it != idx.end(); it++) {         a[(*it)] = mini;         done = true;       }       if (done) {         ans++;       }     };     cout << ans << endl;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t = 1;     cin >> t;     while (t--) {       tc();     }   }   