Problem hidden

FRQPRIME - Frequent Prime Ranges

A range [L..H] is called a K-Frequent Prime range if there are at least K primes amongst the numbers L, L+1 ... H. Given N and K, calculate how many subranges of the range [2..N] are K-Frequent Prime.

Input

The first line contains the number of test cases T. Each of the next T lines contains 2 integers N and K.

Output

Output T lines, one corresponding to each test case, containing the required answer.

Constraints

1 ≤ T ≤ 100

2 ≤ N ≤ 100000

0 ≤ K ≤ 10000

Example

Input:
4
2 1
5 2
5 1
9 3

Output:
1
4
9
8

Explanation

Note: For the first test case, the only valid subrange is [2..2], whereas for the second test case, the valid subranges are: [2..3], [2..4], [2..5], [3..5].


Adicionado por:Varun Jalan
Data:2010-01-25
Tempo limite:1s
Tamanho do fonte:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Linguagem permitida:Todas exceto: ASM64 CLOJURE ERL FSHARP NODEJS OBJC PERL6 PY_NBC SCALA SQLITE TCL VB.NET
Origem:own problem used for Technovanza
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.