#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string x, y;
    cin >> x >> y;
    int l = x.length();
    int i = y.length() - 1;
    while (y[i] != '1') {
      i--;
    }
    i = y.size() - i - 1;
    i = x.size() - i - 1;
    int j = i;
    while (x[i] != '1') {
      i--;
    }
    cout << j - i << endl;
  }
  return 0;
}
