#Lutece0822. F(x)

F(x)

Migrated from Lutece 822 F(x)

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

For a decimal number xx with nn digits (AnAn1An2A2A1A_{n}A_{n-1}A_{n-2}\cdots A_{2}A_{1}), we define its weight as $F(x)=A_{n}\times 2^{n-1}+A_{n-1}\times 2^{n-2}+\cdots +A_{2}\times 2+A_{1}\times 1$. Now you are given two numbers AA and BB, please calculate how many numbers are there between 00 and BB, inclusive, whose weight is no more than F(A)F(A).

Input

The first line has a number TT (T10000T\leq 10000) , indicating the number of test cases.

For each test case, there are two numbers AA and BB (0A,B<1090\leq A,B<10^9)

Output

For every case,you should output Case #t: at first, without quotes. The tt is the case number starting from 11. Then output the answer.

Samples

3
0 100
1 10
5 100
Case #1: 1
Case #2: 2
Case #3: 13

Resources

2013 ACM/ICPC Asia Regional Chengdu Online