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
ks1999:
20180420 17:09:25
My 200th on SPOJ.


m2do:
20180315 21:27:29
1 is considered nonprime. caused me 4 WAs. finally AC :) 

atikahamedutso:
20180128 17:26:50
easy one ac in one go :D


itachi_2016:
20180104 18:49:02
Awesome question @Piyush. Can you look into my code and suggest some improvements if possible. ID : 20920855. 

geet313:
20171217 10:01:53
Sieve works here ? Last edit: 20171217 10:03:36 

omarwageeh:
20170911 09:58:19
make sure you check that all the truncations of a prime that has no zeroes are prime as in the example.... 632647, 32647, 2647, 647, 47, and 7


nihal_magdy:
20170818 11:48:23
@piyush can you see what is the wrong test i get with my code 19995055 

rohit659:
20170406 21:42:37
NICE PROBLEM !!!


dwij28:
20161007 23:40:01
A very nice problem. In fact all problems by @Piyush Kumar i.e the VECTAR series are very nice. :) 

rainy jain :
20160913 02:32:57

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 