SNGPG - Prime Generator The Easiest Question Ever

Prime number questions are always being favorite to everyone. This question is extension to the problem PRIME GENERATOR. The question is very very simple and easier than that you cannot imagine. You have to count total number of such primes p in the range [a ≥ 0, b > 0] so that (p2 + 1) or/and (p2 + 2) is/are prime(s).

Input

First line of input is t, (t < 100) total number of test cases. Next t lines contains two integers a and b separated by space.
a < 50001, b < 100001 and b > a.

Output

In each line print total numbers of such prime numbers.

Example

Input:
2
0 1
4 5 Output: 2
0

[Consider 0 and 1 as prime numbers for this question]


Added by:AvmnuSng
Date:2013-09-08
Time limit:5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Abhimanyu Singh
My Problems

hide comments
2016-02-12 12:08:45
easiest question ever!!!! my 50 th :)
2015-12-26 06:53:52 Siddharth Singh
Though i got an AC , i'm still confused because if i giv input 0 9 it gives me ans of 4
instead of 5
and still it is AC

Last edit: 2015-12-26 06:54:16
2015-11-12 22:37:32 newbie
simplest problem ever got ac in 0.00 :D
2015-08-31 14:24:47
Time limit way too high, with precomputation it takes 0.04s in C++, and the simplest bruteforce without precomputation takes 1.64 :P

Last edit: 2015-08-31 18:19:11
2015-08-19 16:48:36 Vicky
very simple just need observation :P
2015-08-06 15:03:21 pk
Cake Walk ... still got lots of wrong submissions...:)
2015-07-10 22:15:39 scyth3r
this belongs to the category of easier than easiest!!
2015-07-09 22:17:37 :.Mohib.:
Just observe... Easy... :)
2015-06-12 14:17:23 e_coder
@admin...plzz check my code id=14440902
one solution accepted but this gives me WA..plzz
2014-12-18 21:04:22 Aditya Paliwal
Problem statement should state that 2 is prime since if 1 is a prime then beacuse 2%1 = 0, 2 should not be a prime.

Last edit: 2014-12-18 21:04:36
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.