- 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.
- Well ...?
- 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!
- Well, Masha, so you will not so happy as the boys from Lviv and much less frequently.
- Well, I'm the same girl!
The first line contains the number of test cases T (0 ≤ T ≤ 10^4). Each of the following T lines contains a positive integer N, not greater than 2^63 - 1.
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.