#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, i, j, k, p, h;
  string str1, str2;
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> str1;
    cin >> str2;
    for (j = str2.size() - 1; j >= 0; j--) {
      if (str2[j] == '1') break;
    }
    p = j - (str2.size() - 1);
    p = abs(p);
    for (j = str1.size() - 1; j >= 0; j--) {
      if (str1[j] == '1') {
        h = j - (str1.size() - 1);
        h = abs(h);
        if (h >= p) break;
      }
    }
    cout << abs(p - h) << endl;
  }
}
