#include <bits/stdc++.h>
using namespace std;
int main() {
  int T = 0;
  cin >> T;
  for (int t = 0; t < T; ++t) {
    string x;
    cin >> x;
    string y;
    cin >> y;
    int rightY = -1;
    for (int i = y.size() - 1; i >= 0; --i) {
      if (y[i] == '1') {
        rightY = i;
        break;
      }
    }
    rightY = (y.size() - rightY - 1);
    int rightX = -1;
    for (int i = x.size() - 1 - rightY; i >= 0; --i) {
      if (x[i] == '1') {
        rightX = i;
        break;
      }
    }
    rightX = (x.size() - rightX - 1);
    cout << rightX - rightY << "\n";
  }
  return 0;
}
