One testcase is giving TLE
Instead of iterating over p for each test case construct an array of primes such that ith index of that array corresponds to i+1 st prime that way you’d be able to solve each query in O(1)
I tried implementing what you said but I am getting segmentation fault can you see whats wrong?
Okay so I just globally declared the array and got the ans
Thanks
if your doubt is clear please mark it as resolved