Limits 1.5s, 512 MB

In the town of Binaryvile, located in Argentina, there was great anticipation as Lionel Messi, the world champion football player, was scheduled to visit and meet people individually. According to a survey, a large number of people have expressed their interest to meet with Messi one-on-one. However, due to the high number of people, it has become challenging for Messi to meet everyone individually. To ensure fairness, a task has been assigned, and only those who successfully complete it will have the opportunity to meet Messi. As you eagerly await your turn, you understand that solving the task is crucial for meeting your idol. It was an exciting and special opportunity for those who could prove their abilities and have a personal encounter with the famous football star.

You will be given QQ queries, for each query you will be given two integer LL and R.R. Your task is to find the sum of the number of ones in the binary representation of each number within the range and determine whether the resulting sum is a prime number or not.


The first line of input data contains a single integer QQ — indicating the number of queries.

The only line of the each query contains two integers LL and RR separated by space — indicating range of numbers.




Print a single line for each query — “Prime” if the sum of the number of ones in the binary representation of each number within the range is a prime or “Not Prime” otherwise.


1 5
5 10 
12 18
Not Prime


In the first testcase,

  • 1001=11-001=1

  • 2010=12-010=1

  • 3011=23-011=2

  • 4100=14-100=1

  • 5101=25-101=2

Summation of ones in range is (1+1+2+1+2=7).(1+1+2+1+2=7). Now, 77 is a prime number.


Login to submit.


15% Solution Ratio
SaimurEarliest, 8M ago
SaimurFastest, 0.6s
SaimurLightest, 28 MB
SaimurShortest, 790B
Toph uses cookies. By continuing you agree to our Cookie Policy.