Alice and Bob are studying for their class test together. The topic of the test is Prime Numbers. The preparation is getting too boring for their liking. To make it interesting, they turn it into a game. The winner will get an ice-cream treat from the other. 
The game is called Count K-Primes. A number is a k-prime if it has exactly k distinct prime factors. The game is quite simple. Alice will give three numbers A, B & K to Bob. Bob needs to tell Alice the number of K-prime numbers between A & B (both inclusive). If Bob gives the correct answer, he gets a point. If not, Alice gets a point. They play this game T times.
Bob hasn't prepared so well. But he really wants to win the game. He wants you to tell him the correct answer.

Input
First line of input contains a single integer T, the number of times they play. Each game is described in a single line containing the three numbers A,B & K.

Output
For each game, output on a separate line the number of K-primes between A & B.

Constraints:
1 ≤ T ≤ 10000
2 ≤ A ≤ B ≤ 100000
1 ≤ K ≤ 5


Example:

Input
4
2 5 1
4 10 2
14 15 2
2 20 3

Output
4
2
2
0
import sys

max_num = 100001


def count_primes(num_lines):
    is_prime = [1] * max_num
    counts = [0] * max_num
    
    #print "is_prime: ", is_prime

    for p in range(2, max_num):
        if is_prime[p]:
            counts[p] = 1
            j = 2
            while p * j < max_num:
                #print "p: {0}, j: {1}".format(p, j)
                is_prime[p*j] = 0
                counts[p*j] += 1
                j += 1
                
    kp = [[0 for i in range(6)] for j in range(max_num)]
    
    #print "counts: ", counts
    
    #Create running sum of the counts for the unique prime factors in each num from 2 -> max_num
    for i in range(2, max_num):
        for j in range(1, 6):
            kp[i][j] = kp[i-1][j] + (1 if counts[i] == j else 0)
    
    #print "kp: ", kp      
    for i in range(num_lines):
        a, b, k = map(int, sys.stdin.readline().strip().split())
        print kp[b][k] - kp[a-1][k]   


    

s = raw_input()
num_lines = map(int, s.split())[0]            
count_primes(num_lines)