CF2125C.Count Good Numbers

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Count Good Numbers

A prime number is a positive integer that has exactly two divisors: 11 and itself. The first several prime numbers are 2,3,5,7,11,2, 3, 5, 7, 11, \dots.

Prime factorization of a positive integer is representing it as a product of prime numbers. For example:

  • the prime factorization of 111111 is 3373 \cdot 37;
  • the prime factorization of 4343 is 4343;
  • the prime factorization of 1212 is 2232 \cdot 2 \cdot 3.

For every positive integer, its prime factorization is unique (if you don't consider the order of primes in the product).

We call a positive integer good if all primes in its factorization consist of at least two digits. For example:

  • 343=777343 = 7 \cdot 7 \cdot 7 is not good;
  • 111=337111 = 3 \cdot 37 is not good;
  • 1111=111011111 = 11 \cdot 101 is good;
  • 43=4343 = 43 is good.

You have to calculate the number of good integers from ll to rr (endpoints included).

Input

The first line contains one integer tt (1t1031 \le t \le 10^3) — the number of test cases.

Each test case consists of one line containing two integers ll and rr (2lr10182 \le l \le r \le 10^{18}).

Output

For each test case, print one integer — the number of good integers from ll to rr.

Samples

4
2 100
2 1000
13 37
2 1000000000000000000
21
227
7
228571428571428570

在线编程 IDE

建议全屏模式获得最佳体验