#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e3 + 59;
int n, m, kase;
string a, b;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> kase;
  while (kase--) {
    cin >> a;
    cin >> b;
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    int j = 0;
    for (; j < b.length(); ++j) {
      if (b[j] == '1') break;
    }
    int k = 0;
    for (; j < a.length(); j++, k++) {
      if (a[j] == '1') break;
    }
    cout << k << endl;
  }
  return 0;
}
