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