#include <bits/stdc++.h>
using namespace std;
int mv = pow(10, 5) + 1;
void pfn() {
  char x[mv], y[mv];
  cin >> x >> y;
  int ly = strlen(y) - 1, i;
  i = ly;
  while (i >= 0 && y[i] != '1') i--;
  int lx = strlen(x) - 1 - ly + i;
  i = lx;
  while (i >= 0 && x[i] != '1') i--;
  cout << lx - i << '\n';
}
int main() {
  int t;
  cin >> t;
  while (t--) pfn();
}
