#include<stdio.h>
#include<string.h>
#include<math.h>
#define lim 100005
int prime[lim]={0},check[lim]={0};
int main()
{
int i,j,t,a,b,k,s;
s=(int)sqrt(lim)+1;
for(i=2;i<=s;i++)
{
if(!prime[i])
{
check[i]++;
j=2*i;
while(j<=lim)
{
prime[j]=1;
check[j]++;
j+=i;
}
}
}
scanf("%d",&t);
while(t–)
{
int c=0;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&k);
for(i=a;i<=b;i++)
{
if(check[i]==k)
c++;
}
printf("%d\n",c);
}
return 0;
}