#include using namespace std; #define REP(i,n) for(int i=0;i ostream& operator<<(ostream& os,const vector& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; } typedef long long ll; typedef unsigned long long ull; typedef pair pii; typedef vector vi; typedef vector vvi; constexpr ll mod = 1e9+7; constexpr ll max_s = 100010; vector> f; int mod_pow(int x,int n,int m){ int res=1; if(x==0) return 1; x%=m; while(n){ if(n&1) res=(res*x)%m; x=(x*x)%m; n>>=1; } return res; } vector> init(){ vi prime; vector u(max_s,true); u[0] = u[1] = false; //素数列挙 for(int i=2;i> f(max_s,vector(9,0)); for(int p : prime){ for(int num=p;num>s; int n=s.size(); vector v(n); rep(i,n) v[i]=s[i]-'0'; if(*max_element(ALL(v))==0){ cout << "0" << endl; return; } ll ans=0; vector nCk(9,0); for(int i=0;i>T; f = init(); rep(i,T){ solve(); } }