#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s1, s2;
    cin >> s1 >> s2;
    int ans = 0;
    int i = s2.length() - 1;
    while (s2[i] != '1' && i >= 0) {
      i--;
      ans++;
    }
    int k = ans;
    ans = 0;
    i = s1.length() - 1 - k;
    while (s1[i] != '1' && i >= 0) {
      i--;
      ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
