#include <bits/stdc++.h>
long long const gig = 1e18;
long long const md = 1e9 + 7;
long long const N = 2e5;
using namespace std;
long long a[111111];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    string x;
    string y;
    cin >> x >> y;
    reverse(x.begin(), x.end());
    reverse(y.begin(), y.end());
    int k = 0;
    int i = 0;
    while (y[i] == '0' && i != y.size()) i++;
    k = i;
    while (k != x.size() && x[k] == '0') k++;
    cout << abs(k - i) << "\n";
  }
}
