Max limit of prime

What is the max limit of prime required in this program?
Or to say max limit of N?
As in line 15: m<=10000. This will give me prime till 10000. Time limit exceeds. Hence pls resolve this query.

as there are multiple testcases take the prime seive out of the testcases loop…if thats not the issue share the link of your code here

use prime seive only once in your code