T l e oomokmolmol

my code is giving two tle in two test cases

@mayank10
see the constrains
1<=t<=50000
1<=n<=10^6
t*n will order of 10^10. thats why its giving tle

i applied sieve and still getting tle

my all test cases are passed but giving wrong answer in one test case code link https://ide.codingblocks.com/s/223844

@mayank10
refer to this code