Test case 3 of prime visits oh hackerblocks not working

I’ve a doubt in the prime visits problem on hackerblocks. Test case 1 and 2 are working fine but test case 3 is not working. Here is the link of my code:

hello @mayanktyagi

ur program is not efficient .
refer this for efficient approach->

why isnt it efficient?

ur time complexity is high roughy O(q *range^2) .