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