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