#include <bits/stdc++.h>
using namespace std;
char x[100001], y[100001];
int main() {
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    cin >> x >> y;
    int lx = strlen(x), ly = strlen(y), x1, y1;
    for (int i = ly - 1; i >= 0; i--) {
      if (y[i] == '1') {
        x1 = ly - i;
        break;
      }
    }
    for (int i = lx - x1; i >= 0; i--) {
      if (x[i] == '1') {
        y1 = lx - i;
        break;
      }
    }
    cout << y1 - x1 << endl;
  }
  return 0;
}
