#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    string a, b;
    cin >> a >> b;
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    int index = b.length(), index2 = a.length();
    for (int i = 0; i < b.length(); i++) {
      if (b[i] == '1') {
        index = i;
        break;
      }
    }
    for (int i = index; i < a.length(); i++) {
      if (a[i] == '1') {
        index2 = i;
        break;
      }
    }
    cout << index2 - index << endl;
  }
  return 0;
}
