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