Please optimise my code,it is giving tle

hey @sattyrajpoot39, the problem you are making seive for every testcase, thatswhy it is taking so much of time. Make Sieve first and than take t as input.