IIITA1 - Playing With Bits

no tags 

Maaz and Aradhya are quite brilliant students of Mathematics and Programming respectively. One day, their Mathematics Professor Mr. K.P. Singh asked them to solve a Mathematics problem.

Given two number A and B, find the minimum number of bits required to convert binary representation of A into binary representation of B.

Maaz promised Mr. K.P. Singh that he will be the first one to solve the problem but Aradhya decided to do it before him. He turns to you for help. Will you be able to help him?

Input

Input consists of t (number of test cases), then t lines follows, each containing two integers A and B (1 <= A, B <= 2^31)

Output

A single line containing the minimum number of bits required to convert binary representation of  A into binary representation of B.

Example

Input:
2
14 31
56 68
Output:
2
5

Time Limit is kept very strict. Any naive algorithm will never be accepted. 


hide comments
Francky: 2012-08-26 16:31:09

Should be moved to challenge. It's just now too IO related ! (Is a scanf solution possible ?)
EDIT : 0.07s with scanf is possible.
What are the full constraints ? How about t ?

Re -> 1 < t < 6000

Last edit: 2012-08-26 05:37:05

Added by:Better late than never !!!
Date:2012-08-25
Time limit:0.100s
Source limit:500B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Navneet Sir