#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll elso_1(string x) {
  ll res = 0;
  while (x.back() != '1') {
    x.pop_back();
    res++;
  }
  return res;
}
void processs() {
  string x, y;
  cin >> x >> y;
  reverse(x.begin(), x.end());
  reverse(y.begin(), y.end());
  ll i = 0;
  while (y[i] == '0') i++;
  ll ans = 0;
  while (x[i] == '0') {
    ans++;
    i++;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  ll T;
  cin >> T;
  for (ll i = 1; i <= T; i++) {
    processs();
  }
}
