#include <bits/stdc++.h>
using namespace std;
const long long OO = 1e8;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
void solve() {
  string s1, s2;
  cin >> s1 >> s2;
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  int index2 = 0;
  while (s2[index2] != '1') index2++;
  int counter = 0;
  while (s1[index2] != '1') counter++, index2++;
  cout << counter << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
