#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 100;
char s[maxn], t[maxn];
void work() {
  scanf("%s", s);
  scanf("%s", t);
  int n = strlen(s);
  int m = strlen(t);
  reverse(s, s + n);
  reverse(t, t + m);
  int i = 0;
  for (; t[i] == '0'; i++)
    ;
  int ans = 0;
  while (s[i + ans] == '0') ans++;
  printf("%d\n", ans);
}
int main() {
  int TestCase = 1;
  scanf("%d", &TestCase);
  while (TestCase--) {
    work();
  }
  return 0;
}
