#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string x, y;
    cin >> x >> y;
    reverse(y.begin(), y.end());
    reverse(x.begin(), x.end());
    int k = y.size();
    for (int i = 0; i < y.size(); i++) {
      if (y[i] == '1') {
        k = i;
        break;
      }
    }
    for (int i = k; i < x.size(); i++) {
      if (x[i] == '1') {
        cout << i - k << endl;
        break;
      }
    }
  }
}
