#include <bits/stdc++.h>
using namespace std;
const int maxn = 131072;
const int INF = 1e9;
const long long mod = 1e9 + 7;
const long double pi = acos(-1);
const long double eps = 1e-6;
int steps[101];
void solve() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    string s1, s2;
    cin >> s1 >> s2;
    reverse(s2.begin(), s2.end());
    reverse(s1.begin(), s1.end());
    int pos = 0;
    for (; pos < s2.size(); pos++) {
      if (s2[pos] == '1') break;
    }
    int tmp = pos;
    for (; pos < s1.size(); pos++) {
      if (s1[pos] == '1') break;
    }
    cout << pos - tmp << endl;
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(4) << fixed;
  solve();
  return 0;
}
