ERROR: TLE, MAJIIN VEGETA

I don’t kmow, but I am getting an error TLE in my code, i have tried many times and still the error persists.
I request you to please help me correcting my code.

Here is my code: https://www.codechef.com/viewsolution/18948944
Link to question: https://www.codechef.com/problems/VEGETA
Problem code: VEGETA

As you are calling sieve for each query. Bring sieve function call out of while loop.