#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    string s1, s2;
    cin >> s1 >> s2;
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());
    int k, j;
    for (j = 0; j < s2.size(); j++) {
      if (s2[j] == '1') {
        k = j;
        break;
      }
    }
    for (j = k; j < s1.size(); j++) {
      if (s1[j] == '1') {
        k = j - k;
        break;
      }
    }
    cout << k << endl;
  }
  return 0;
}
