#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 ix = 1e9, iy = 1e9;
    for (int i = 0; i < y.size(); i++) {
      if (y[i] == '1') {
        iy = min(iy, i);
      }
    }
    for (int i = iy; i < x.size(); i++) {
      if (x[i] == '1') {
        ix = min(ix, i);
      }
    }
    if (ix == iy) {
      cout << 0 << endl;
      continue;
    }
    cout << ix - iy << endl;
  }
}
