宁芙奖请投佣兵
#include<iostream>
using namespace std;
long long b,x,y,n,m,s[20];
int pd(long long a){
b++;
s[b]=a;
for(int i =0;i<b;i++){
if(a==s[i]){
return 2;
}
}
if(a==0){
return 0;
}
return(pd(a/10));
}
int qwq(long long a){
for(int i =2;i<m;i++){
if(a%i==0){
return 0;
}
}
return 1;
}
int main(){
cin>>x;
for(int o =0;o<x;o++){
cin>>n>>m;
y=0;
for(int q = n;q<=m;q++){
for(int w=0;w<20;w++){
s[w]==0;
}
b=0;
if(pd(q)==0&&qwq(q)==1){
y++;
}
}
cout<<y;
}
}