Problems
Lucky number Masha
Lucky number Masha
\includegraphics{https://static.e-olymp.com/content/2a/2a3679458f8dc7a23638f9d1e09376a4df3b89bf.jpg}
\textit{- Listen, Michael, we were told in school that somewhere in the world there is a city of Lviv, where young pretty boys say that happy digits are 4 and 7.}
\textit{- Well ...?}
\textit{- So Mike, I came up with his lucky number - 47. And I'll be happy every time in any number up to a specified number meet these two figures together to form my lucky number!}
\textit{- Well, Masha, so you will not so happy as the boys from Lviv and much less frequently.}
\textit{- Well, I'm the same girl!}
\InputFile
The first line contains the number of test cases \textbf{T} (\textbf{0} ≤ \textbf{T} ≤ \textbf{10^4}). Each of the following \textbf{T} lines contains a positive integer \textbf{N}, not greater than \textbf{2^63} - \textbf{1}.
\OutputFile
For each test case print in a separate line the number of occurrences of all positive integers up to and including the specified subsequence of digits in the form of a happy Masha numbers.
Input example #1
5 4 7 50 200 550
Output example #1
0 0 1 2 16
Example description: From 1 to 550, the numbers that include the sub-sequence "47" are "47", "147", "247", "347", "447", "470", "471", "472", "473", "474", "475", "476", "477", "478", "479", "547", so the answer is 16.