Surprising Prime
题号:NC231902
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

On the Land of Tiwat, there are various kind of number. But in so many numbers, we called a number "Surprising Number" if and only if it is a prime number and can be expressed as the sum of two square numbers.

A prime number is defined as a number n that has no factors other than 1 and n.

A square number is defined as a number n that there is an positive integer x satisfying .

For example, 13 is a prime number and , so 13 is a "Surprising Number".

Now, give you q times query, for each query you're asked to calculate how many "Surprising Number" there are in the given interval ?

输入描述:

The first line contains the number  denoting the times of query.

Following q lines each contains two integers denoting the given interval.

输出描述:

For each query, output one line containing one integer, denoting the number of "Surprising Number" in the given interval.
示例1

输入

复制
2
1 5
1 10

输出

复制
2
2