You Are Given Two Binary Strings...
Contest: Educational Codeforces Round 70 (Rated for Div. 2)
Difficulty rating: 1100
Tags: bitmasks, greedy

You are given two binary strings $$$x$$$ and $$$y$$$, which are binary representations of some two integers (let's denote these integers as $$$f(x)$$$ and $$$f(y)$$$). You can choose any integer $$$k \ge 0$$$, calculate the expression $$$s_k = f(x) + f(y) \cdot 2^k$$$ and write the binary representation of $$$s_k$$$ in reverse order (let's denote it as $$$rev_k$$$). For example, let $$$x = 1010$$$ and $$$y = 11$$$; you've chosen $$$k = 1$$$ and, since $$$2^1 = 10_2$$$, so $$$s_k = 1010_2 + 11_2 \cdot 10_2 = 10000_2$$$ and $$$rev_k = 00001$$$.

For given $$$x$$$ and $$$y$$$, you need to choose such $$$k$$$ that $$$rev_k$$$ is lexicographically minimal (read notes if you don't know what does "lexicographically" means).

It's guaranteed that, with given constraints, $$$k$$$ exists and is finite.

Input format:
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries.

Next $$$2T$$$ lines contain a description of queries: two lines per query. The first line contains one binary string $$$x$$$, consisting of no more than $$$10^5$$$ characters. Each character is either 0 or 1.

The second line contains one binary string $$$y$$$, consisting of no more than $$$10^5$$$ characters. Each character is either 0 or 1.

It's guaranteed, that $$$1 \le f(y) \le f(x)$$$ (where $$$f(x)$$$ is the integer represented by $$$x$$$, and $$$f(y)$$$ is the integer represented by $$$y$$$), both representations don't have any leading zeroes, the total length of $$$x$$$ over all queries doesn't exceed $$$10^5$$$, and the total length of $$$y$$$ over all queries doesn't exceed $$$10^5$$$.

Output format:
Print $$$T$$$ integers (one per query). For each query print such $$$k$$$ that $$$rev_k$$$ is lexicographically minimal.

Constraints:
Time limit: 2.0 s
Memory limit: 256.0 MB

Note:
The first query was described in the legend.

In the second query, it's optimal to choose $$$k = 3$$$. The $$$2^3 = 1000_2$$$ so $$$s_3 = 10001_2 + 110_2 \cdot 1000_2 = 10001 + 110000 = 1000001$$$ and $$$rev_3 = 1000001$$$. For example, if $$$k = 0$$$, then $$$s_0 = 10111$$$ and $$$rev_0 = 11101$$$, but $$$rev_3 = 1000001$$$ is lexicographically smaller than $$$rev_0 = 11101$$$.

In the third query $$$s_0 = 10$$$ and $$$rev_0 = 01$$$. For example, $$$s_2 = 101$$$ and $$$rev_2 = 101$$$. And $$$01$$$ is lexicographically smaller than $$$101$$$.

The quote from Wikipedia: "To determine which of two strings of characters comes when arranging in lexicographical order, their first letters are compared. If they differ, then the string whose first letter comes earlier in the alphabet comes before the other string. If the first letters are the same, then the second letters are compared, and so on. If a position is reached where one string has no more letters to compare while the other does, then the first (shorter) string is deemed to come first in alphabetical order."

Example input:
4
1010
11
10001
110
1
1
1010101010101
11110000

Example output:
1
3
0
0

Editorial:
Multiplying by power of $$$2$$$ is "shift left" binary operation (you, probably, should know it). Reverse $$$x$$$ and $$$y$$$ for the simplicity and look at leftmost $$$1$$$ in $$$y$$$ (let's denote its position as $$$pos_y$$$).
If you move it to $$$0$$$ in $$$x$$$ then you make the $$$rev_k$$$ lexicographically bigger than the reverse of $$$x$$$. So you should move it to $$$1$$$ in $$$x$$$ too. You can choose any $$$1$$$ with position $$$\ge pos_y$$$.
Let $$$pos_x$$$ be the minimum position of $$$1$$$ in $$$x$$$, such that $$$pos_x \ge pos_y$$$. You must move $$$pos_y$$$ to $$$pos_x$$$, otherwise the $$$1$$$ in $$$pos_x$$$ still be present in $$$rev_k$$$ and it will be not optimal.
So, the solution is next: reverse $$$x$$$ and $$$y$$$, find $$$pos_y$$$, find $$$pos_x \ge pos_y$$$, print $$$pos_x - pos_y$$$.