Madhu's Silly Number

5

2 votes
Binary Search, Implementation, Medium
Problem

Madhu is a chemistry honour’s student but she always wanted to learn competitive programming. So, she went to the best institution in the town. They gave her a question as an entrance test to check her skills. You as the best coder of the town need to help Madhu, so that she qualify her test.

A number is called silly number if it consist of number no other than (3, 7). You need to find the total silly number X between K1 and K2.

The first few silly numbers are (3, 7, 33, 37, 73……)

 

Input

The first line of input contains the only integer denoting the number of testcases.

Second line contains contains two integers K1 and K2.

Output

Print the total silly number X between K1 and K2.

NOTE: The next silly number of a silly number is number itself

Constraints

1 ≤  T ≤ 105

0 ≤ K1, K2 ≤ 1016

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For 4th Test Case their are 6 silly number between 1 and 100 
3,7,33,37,73,77

Editor Image

?