#include <bits/stdc++.h>
using namespace std;
const int mxn = 1e6 + 5;
const long long MOD = 1e9 + 7;
int arr[mxn];
int n;
string x, y;
void solve() {
  int k = 0;
  int last_ind = y.size() - 1;
  while (y[last_ind] == '0') k++, last_ind--;
  last_ind = x.size() - k - 1;
  k = 0;
  while (last_ind >= 0 && x[last_ind] == '0') k++, last_ind--;
  cout << k << '\n';
}
void read() { cin >> x >> y; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int T = 1;
  cin >> T;
  while (T--) read(), solve();
  return 0;
}
