A winter cloth distribution campaign will be held in the city of BugBlossoms. There are two orphanages separated by a river, and each orphanage has $$$n$$$ rooms numbered from $$$1$$$ to $$$n$$$ from left to right. Crossing the river takes $$$k$$$ units of time. Each room is either empty or occupied by a single child (represented by each character 1 in the input strings).
As Ad-Duha is managing the campaign alone, she has decided to keep all the winter clothing packages in a single room — that is, in exactly one of the $$$2n$$$ rooms across both orphanages — due to a lack of volunteers. The children from every occupied room in both orphanages must come to that chosen room to collect their winter clothes.
If the packages are located in room $$$i$$$ of an orphanage and a child is in room $$$j$$$:
Ad-Duha wants to choose the room so as to minimize the maximum time any child spends reaching the room containing the packages.
Once this room is chosen, the children are split into two groups:
Ad-Duha felt sad that the children in Group B had to cross the river to receive their winter clothes, so she decided to give them books, flowers and chocolates as well. She has $$$m$$$ gift boxes in total. Each child in Group A gets exactly $$$x$$$ boxes, and each child in Group B gets exactly $$$y$$$ boxes, where:
The total $$$a \cdot x + b \cdot y$$$ must not be more than $$$m$$$. Ad-Duha wants to give away as many boxes as possible. Find the minimum number of boxes that remain ungifted.
The first line contains an integer $$$T$$$ — the number of test cases.
Each test case is described as follows:
It is guaranteed that each of the two strings contains at least two 1s, so whichever orphanage is chosen, $$$a \ge 1$$$ and $$$b \ge 2$$$.
It is also guaranteed that $$$a + 2b \le m$$$ for whichever orphanage is chosen. That is, both $$$c_1 + 2c_2 \le m$$$ and $$$c_2 + 2c_1 \le m$$$, where $$$c_1$$$ and $$$c_2$$$ are the numbers of 1s in the first and second string.
Constraints:
For each test case, print the following three lines:
If the minimum time can be reached by placing the packages in orphanage 1 and also by placing them in orphanage 2, you may take either orphanage as the one with the packages when you compute $$$a$$$ and $$$b$$$. Any of the resulting answers for the third line is accepted.
Every test case must print exactly three lines. If you cannot compute some part, print -1 in its place:
| Subtask | Points | $$$T$$$ | $$$n$$$ | Additional Constraints |
| 0 | 0 | - | - | The examples |
| 1 | 30 | $$$\le 10$$$ | $$$\le 10^3$$$ | No additional constraints. |
| 2 | 30 | - | $$$\le 10^3$$$ | No additional constraints. |
| 3 | 40 | - | - | No additional constraints. |
All other constraints are the same as in the Input section.
Each test case in a file is scored separately, and the score of the file is the average over its test cases. For one test case:
If the first line is wrong, the whole test case scores $$$0$$$.
55 3 2010100001016 10 411000010100104 1 15111000114 2 11110101103 1 8111110
7 2 1 0 16 1 1 1 5 2 1 1 6 1 1 0 4 1 1 1
Test 1: The first orphanage has children in rooms $$$1$$$ and $$$3$$$, and the second in rooms $$$3$$$ and $$$5$$$.
Placing the packages in room $$$1$$$ of the second orphanage:
Test 2: Placing the packages in room $$$1$$$ of the first orphanage: