#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int BASE = 1e9 + 7;
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  string x, y;
  cin >> T;
  while (T--) {
    cin >> x >> y;
    reverse(x.begin(), x.end());
    reverse(y.begin(), y.end());
    int pos, ans;
    for (int i = 0; i < y.size(); i++) {
      if (y[i] == '1') {
        pos = i;
        break;
      }
    }
    for (int i = pos; i < x.size(); i++) {
      if (x[i] == '1') {
        ans = i - pos;
        break;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
