#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, d, d1, d2, n1, n2, id, id1;
  char ch;
  cin >> t;
  string st, st1, st2, st3;
  while (t--) {
    cin >> st;
    cin >> st1;
    reverse(st.begin(), st.end());
    reverse(st1.begin(), st1.end());
    n1 = st.length();
    n2 = st1.length();
    for (long long int i = 0; i < n2; i++) {
      if (st1[i] == '1') {
        id1 = i;
        break;
      }
    }
    for (long long int i = 0; i < n1; i++) {
      if (st[i] == '1') {
        id = i;
        if (id >= id1) break;
      }
    }
    d = abs(id - id1);
    cout << d << endl;
  }
  return 0;
}
