PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000079. Đếm số có đúng k ước nguyên tố phân biệt (Bedao Regular Contest 03 - PRIME)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm số có đúng k ước nguyên tố phân biệt (Bedao Regular Contest 03 - PRIME)

Bedao Regular Contest 03 - PRIME

Source: VNOJ

Version: Phuoc Hung OJ Extended

Problem Statement

You are given QQ range queries (a,b,k)(a,b,k). For each query, count the integers xx with a≤x≤ba\le x\le b that have exactly kk distinct prime divisors. For instance, 6=2⋅36=2\cdot3 has two distinct prime divisors, while 8=238=2^3 has one.

Input

The first line contains the number of queries QQ. Each of the next QQ lines contains three integers a,b,ka,b,k in that order.

Output

Print QQ lines, one answer for each query, in the original order.

Subtasks

  • Subtask 1 (40 points): 1≤Q≤10001\le Q\le 1000; 1≤ai≤bi≤10001\le a_i\le b_i\le 1000; 1≤ki≤71\le k_i\le7 for every query 1≤i≤Q1\le i\le Q.
  • Subtask 2 (60 points): 1≤Q≤1000001\le Q\le 100000; 1≤ai≤bi≤10000001\le a_i\le b_i\le 1000000; 1≤ki≤71\le k_i\le7 for every query 1≤i≤Q1\le i\le Q.

Examples

Input

2
3 6 2
7 10 1

Output

1
3

Explanation

In [3,6][3,6], only 6=2⋅36=2\cdot3 has two distinct prime divisors, so the first answer is 11. In [7,10][7,10], 77, 8=238=2^3, and 9=329=3^2 have exactly one distinct prime divisor, whereas 10=2⋅510=2\cdot5 has two. The second answer is 33.