#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
namespace SOLVE {
void main() {
  string a, b;
  cin >> a >> b;
  if (b == "0") {
    cout << 0 << endl;
    return;
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  int ai = -1, bi = -1;
  for (long long i = 0; i < b.length(); i++) {
    if (b[i] == '1') {
      bi = i;
      break;
    }
  }
  for (long long i = bi; i < a.length(); i++) {
    if (a[i] == '1') {
      ai = i;
      break;
    }
  }
  int ans = ai == -1 ? 0 : ai - bi;
  cout << ans << endl;
}
}  // namespace SOLVE
signed main() {
  int t;
  cin >> t;
  while (t--) {
    SOLVE::main();
  }
  return 0;
}
