for i in range(int(input())):
s1 = input()
s2 = input()
s = s1+s2
se = set(s)
print(len(se)-1)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int dt=86400;
#define pb push_back
#define ff first
#define ss second
const ll c=2022;
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
// freopen("input.txt","r", stdin);
int t;cin>>t;
while(t--){
string s1, s2; cin>>s1>>s2;
set<char> cnt;
for(char c:s1){
cnt.insert(c);
}
for(char c:s2){
cnt.insert(c);
}
cout << cnt.size()-1 << endl;
}
return 0;
}
1712C - Sort Zero | 1028B - Unnatural Conditions |
735B - Urbanization | 746C - Tram |
1278B - A and B | 1353D - Constructing the Array |
1269C - Long Beautiful Integer | 1076A - Minimizing the String |
913C - Party Lemonade | 1313A - Fast Food Restaurant |
681A - A Good Contest | 1585F - Non-equal Neighbours |
747A - Display Size | 285A - Slightly Decreasing Permutations |
515C - Drazil and Factorial | 1151E - Number of Components |
1151F - Sonya and Informatics | 556A - Case of the Zeros and Ones |
867A - Between the Offices | 1569A - Balanced Substring |
260A - Adding Digits | 1698C - 3SUM Closure |
1029B - Creating the Contest | 1421A - XORwice |
1029A - Many Equal Substrings | 1675D - Vertical Paths |
1271C - Shawarma Tent | 805A - Fake NP |
1163A - Eating Soup | 787A - The Monster |