#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
vector<int> v;
map<int, int> mp;
int main() {
  ios::sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) {
    string s1, s2;
    cin >> s1 >> s2;
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());
    int len1 = s1.size();
    int len2 = s2.size();
    int pos1 = -1, pos2 = -1;
    for (int i = 0; i < len2; i++) {
      if (s2[i] == '1') {
        pos2 = i;
        break;
      }
    }
    for (int i = pos2; i < len1; i++) {
      if (s1[i] == '1') {
        pos1 = i;
        break;
      }
    }
    if (pos1 == pos2)
      cout << 0 << endl;
    else
      cout << pos1 - pos2 << endl;
  }
  return 0;
}
