#include <bits/stdc++.h>
const int maxn = 1010;
const int maxm = 1e5 + 5;
using namespace std;
int main() {
  int T;
  scanf("%d", &T);
  int cas = 0;
  while (T--) {
    string a, b;
    cin >> a >> b;
    int sa, sb;
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    for (int i = 0; i < b.size(); i++) {
      if (b[i] == '1') {
        sb = i;
        break;
      }
    }
    for (int i = sb; i < a.size(); i++) {
      if (a[i] == '1') {
        sa = i;
        break;
      }
    }
    cout << sa - sb << endl;
  }
  return 0;
}
