#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
while (n--){
int m=0;
string s, t;
cin >> s >> t;
if(s.length()>t.length()) swap(s, t);
for(int i=s.length()-1; i>=0; i--){
if(s[i]-'0'+t[i]-'0'>=10){
m++;
if(i!=0){
s[i-1]++;
}
}
}
cout << m << endl;
}
return 0;
}