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