#include <bits/stdc++.h>
using namespace std;
string a, b;
int x, n, i, k, j;
int main() {
  cin >> x;
  for (int y = 0; y < x; y++) {
    cin >> a >> b;
    n = 0;
    i = b.length() - 1;
    while (b[i] == '0') {
      n++;
      i--;
    }
    k = 0;
    j = a.length() - n - 1;
    while (a[j] == '0') {
      j--;
      k++;
    }
    cout << k << endl;
  }
}
