13021 - Longest Binary Distance   

Description

Binary distance for an integer is the number of "0" between two adjoining "1"s in the binary representation of an integer. For example, the binary representation of 37 is 1001012, so 37 has two binary distances which are 2 and 1.

If there aren't any "0"s between two adjoining "1"s, the binay distance will be 0. e.g. 7 (1112) has two binary distances = 0.

If the number of "1" in the binary representation is less than 2, the binay distance will be -1. e.g. 8(10002) only has one binary distances = -1.

In this problem, you are asked to compute the longest binary distances for the given q integers.

For example, if the input integer is 37, you should output 2 as the answer.

Input

First line countains an integer which denotes q. (1 ≤ q ≤ 20)

Then, q lines follow.

Each line contains one integer N (0 ≤ N ≤ 263 - 1).

Output

Output contains q lines and each line contain the longest binary distance of the input integer ended with '\n'. 

Sample Input  Download

Sample Output  Download

Tags




Discuss