VECTAR8  Primal Fear
Changu and Mangu are afraid of prime numbers, but they are not afraid of all prime numbers. They were afraid of only a special kind of prime numbers. They are afraid of the prime numbers (without the digit zero, they love all the primes which have digits 0 in them) that remain prime no matter how many of the leading digits are omitted. For example, they are afraid of 4632647 because it doesn't have the digit 0 and each of its truncations (632647, 32647, 2647, 647, 47, and 7) are primes.
You are given a simple task, given a number of N, find out the number of primes not greater that N, that changu and mangu are afraid of.
Input
The first line contains T, the number of test cases. T lines follow, each containing a number N.
Output
On each line print the number of primes not greater that N, that changu and mangu are afraid of.
Example
Input: 3 2 3 4 Output: 1 2 2
Constraints
T ≤ 10^5
1 ≤ N < 10^6
hide comments
ashutosh_aswal:
20200718 08:34:10
All comments are just Ac in this much, Ac in that much.


atom_jojo:
20200711 09:31:20
AC in 0.02 sec using sieve and precalculation in cpp 

spoj_mradul:
20200116 16:03:55
getting TLE in python 3.7 but AC in PyPy in 0.18 sec :) Last edit: 20200116 16:04:25 

akhilkumar31e:
20191017 08:22:42
I am getting TLE after I used sieve and precomputation.View my solution and suggest edit.ID:24626264


sid779:
20190630 10:00:31
AC in 3rd go :) read carefully " they are afraid of 4632647 because it doesn't have the digit 0 and each of its truncations (632647, 32647, 2647, 647, 47, and 7) are primes. " 

ajkdrag:
20190608 16:45:58
For java submissions, I am getting TLE, even though my code is pretty well optimized  23895740 

selfcoder24:
20190604 10:17:49
Nice problem.


uvshuvo:
20180613 20:05:51
very nice problem. thanks 

ks1999:
20180420 17:09:25
My 200th on SPOJ.


m2do:
20180315 21:27:29
1 is considered nonprime. caused me 4 WAs. finally AC :) 
Added by:  Piyush Kumar 
Date:  20160704 
Time limit:  0.300s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 GOSU JSMONKEY 