#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  int T;
  cin >> T;
  while (T--) {
    cin >> s1 >> s2;
    int x2 = 1;
    while (s2[s2.size() - x2] == '0') x2++;
    int x1 = x2;
    while (s1[s1.size() - x1] == '0') x1++;
    cout << x1 - x2 << '\n';
  }
  return 0;
}
