eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Lucky Numbers

Lucky Numbers

John has recently arrived in Bucharest for the South Eastern European Regional Contest. John is famous for his theory of lucky numbers. That's why all the contestants and spectators are very happy. According to that theory \textbf{4} and \textbf{7} are lucky digits, and all the other digits are not lucky. A lucky number is a number that contains only lucky digits in decimal notation. A very lucky number is a number that can be expressed as a product of several lucky numbers. A lucky number by itself is considered to be very lucky. For example, numbers \textbf{47}, \textbf{49}, \textbf{112} are very lucky. Your task is to calculate the number of very lucky numbers that are not less than \textbf{A} and not greater than \textbf{B}. Of course, numbers \textbf{A} and \textbf{B} are given by John. \InputFile The first line of the input contains a single integer \textbf{T} - a number of test cases. Each of the next \textbf{T} lines contains two integers separated by a single space - \textbf{A} and \textbf{B}. Constrains: \textbf{1} ≤ \textbf{T} ≤ \textbf{7777}, \textbf{1} ≤ \textbf{A} ≤ \textbf{B} ≤ \textbf{1000000000000} (\textbf{10^12}). \OutputFile Output must contain \textbf{T} lines - answers for the test cases.
Лимит времени 3 секунды
Лимит использования памяти 64 MiB
Входные данные #1
4
1 2
88 99
112 112
1 100
Выходные данные #1
0
0
1
10