Given a range L to R, the task is to find the highest occurring digit in prime numbers which lie between L and R (both inclusive). If multiple digits have same highest frequency print the largest of them. If no prime number occurs between L and R, output -1.
The first line of input contains T denoting number of test cases. The only line of each test case contains two integers L and R, denoting the range.
For each test case output a single line containing the answer.
1<= T <= 5000
2<= L<=R <= 10^6
Prime number between 2 and 20 are 2, 3, 5, 7, 11, 13, 17, 19. 1 occur maximum i.e 5 times among 0 to 9.
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?Yes