I have made my efficient stiil getting error time limit exede
Hey @Jan19LPN0013, complexity of your code is very high, first of all make a sieve of eratosthenes and than proceed with each test case.
If you are not aware of sieve of eratosthenes, read it on some blogs and watch some videos.
Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. 