Bit Friendship Index
InterviewTime limit1sMemory limit128 MB
Given two equal-length binary strings, find the minimum number of digit changes and character swaps to make them identical.
Problem
Jinhong likes numbers. While playing with them today he worked out the bit friendship index of two numbers.
The bit friendship index of two binary numbers is the smallest number of operations needed to make them equal. Two operations are allowed.
- In one of the two binary numbers, change the digit at any position to 0 or 1.
- In one of the two binary numbers, swap the digits at two different positions.
For example, take the decimal numbers 11 and 12. In binary they are 1011 and 1100. Changing the digit in the 2s place of 1011 to 0 gives 1001, and swapping the digit in the 1s place with the digit in the 4s place then gives 1100. Two operations are enough and no shorter sequence exists, so the bit friendship index of 11 and 12 is 2.
Jinhong wants a program that takes two numbers and reports their bit friendship index. He is weak at programming and can only convert a decimal number to binary. Help him and write that program.
Input
The first line contains the number of test cases ().
Each test case is a single line holding two binary numbers and separated by a space. and have the same digit count, and that count is at most 1,000,000. Leading zeros can appear.
Output
For each test case, print the bit friendship index of and on its own line.