#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string a, b;
    cin >> a >> b;
    reverse((a).begin(), (a).end());
    reverse((b).begin(), (b).end());
    int posy = b.find('1');
    int posx = a.find('1', posy);
    cout << posx - posy << "\n";
  }
}
